Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do i disable the reset button for one player?

Asked by 2 years ago
Edited 2 years ago

I'm using this script so that a player cant reset in a specific area, i also tried making it a local script but it just disables it for everyone:

game.Workspace.epicpart.Touched:Connect(function()
    game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)
    wait(34)
    game:GetService("StarterGui"):SetCore("ResetButtonCallback", true)
end)

So, is there any way to disable the reset button just for one player?

1 answer

Log in to vote
2
Answered by
ultrabug 306 Moderation Voter
2 years ago

Here's something I threw together that seems to work for this. So, the call actually has to be made from a local script, and as long as that local script's function only runs for the specific player that you want then it should work. The way I did this was by having a script in the part that gets touched, a remote event that the script and the local script can access, and a local script. The script detects the hit, and then works out which player it needs to fire the remote event for. The local script waits until it gets fired(which only happens for the specific player's version of the local script) and then toggles the reset thing.

Script code:

local event = game:GetService("ReplicatedStorage").RemoteEvent
local debounce = false
script.Parent.Touched:Connect(function(hit)
    if debounce == false then
        debounce = true
        if hit.Parent:FindFirstChild("Humanoid") then
            local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
            event:FireClient(player)
        end
    end
    wait(5)
    debounce = false
end)

Local script:

local gui = game:GetService("StarterGui")
local reset = false

function ToggleReset()
    if reset == false then
        gui:SetCore("ResetButtonCallback", false)
        reset = true
    else 
        gui:SetCore("ResetButtonCallback", true)
        reset = false
    end

end

game:GetService("ReplicatedStorage").RemoteEvent.OnClientEvent:Connect(ToggleReset)

1
Thank you so much it works! hellmet1 42 — 2y
Ad

Answer this question