debuggingscriptingrobloxproximity

How can I add cooldown to this proximityprompt for local player only


enter image description here

I want to add a cooldown to the proximitypropmt for only local players, meaning that there will be no cooldown for other players until they use the proximity too, thanks in adavance!

enter image description here I tried using this method and it kinda worked but for some reason it duplicated all the existing "pizzas" in my invenotry whenever i triedd to grab a new one


Solution

  • Instead of using a server script you can put the following inside a localscript and place it inside the StarterPlayerScripts. This way the server does not have to track who triggered the proximity.

    local db = false
    local proxy = [YourProxyPath].Triggered:Connect(function(plr)
        if not db then 
            db = true
            print("triggered") 
            -- tell server to give items to the player using remoteEvent
        end
        wait(5)
        db = false
    end)