Please review my script IDK if this is right

local debounce = false

script.Parent.Headquarters.MouseButton1Click:Connect(function()
    if not debounce then
        game.ReplicatedStorage.FindFirstChild("ChangeTeam"):FireClient("Headquarters")
        debounce = true
        wait(120)
        debounce = false
    end
end)

script.Parent.Manager.MouseButton1Click:Connect(function()
    if not debounce then
        game.ReplicatedStorage.FindFirstChild("ChangeTeam"):FireClient("Manager")
        debounce = true
        wait(120)
        debounce = false
    end
end)
1 Like

IDK what exactly you are making, but if you are trying to change the player team with a local script, this will not work.
For you to change the player team you need to make that on a server script.

Thats why I’m using remote event

So, send the server script, because I think no have any issue on this script

One thing I’m noticing is that you do not call :GetService on roblox Services such as ReplicatedStorage.
Another thing is that you are firing a remote event to the client when this is already on the client, therefore that will not work. Instead, you would fire the server and the server would handle all the changing teams etc. I also recommend using the task library, task.wait() or task.delay() for debouncing.

any docs how to use task.wait() or task.delay()?

You forgot the colon when calling FindFirstChild, but you shouldn’t use FindFirstChild here anyways. Only use it in scenarios when you aren’t sure if something exists or you need to find the first descendant. In this case you’re doing neither.

Thanks

justfor30chars blahblahblah

Those :FireClient("Manager") and :FireClient("Headquarters") could be in one event. You just need to specify the team that It’s going to change to. Not too hard and It would definitely reduce your script size and make It more understandable.