I'm trying to make a gui to host a sword fight thing and I'm adding a cooldown to prevent abuse and it's not changing the value. I've tried editing the code, putting it in serverscriptservice, in the gui, in workspace, none work.
game.ReplicatedStorage.CooldownStart.OnServerEvent:Connect(function()
if game.ReplicatedStorage.FIghtStarted.Value == false then
game.ReplicatedStorage.FIghtStarted.Value = true
game.ReplicatedStorage.NameStorageDupe.Value = script.Parent.Parent.Parent.Name
game.ReplicatedStorage.ParticipateFight:FireAllClients()
game.ReplicatedStorage.Cooldown.Value = 520
while true do
game.ReplicatedStorage.Cooldown.Value = game.ReplicatedStorage.Cooldown.Value - 1
wait(1)
if game.ReplicatedStorage.Cooldown.Value == 0 then
game.ReplicatedStorage.FIghtStarted = false
game.ReplicatedStorage.Cooldown.Value = 520
break
end
end
end
end)
Please help, is it where I'm putting it? It used to be just on mousebutton1up it runs but I tried changing it to OnServerEvent nothing is working

2 comments
please use more variables this code is very messy. for example local FightStarted = game.ReplicatedStorage.FIghtStarted.
It wasnt working when i used local but it works now so its fine