i made a team change Gui that changes your team using remote event I realised that the players can spam the remote event this can cause lag since the player spams changing his team. tried using debounce on the client side but the exploiters can read/write everything in the client side so is there a way to prevent them from the server side . this is the team change code local script
script.Parent.MouseButton1Click:Connect(function() local Fire = game.ReplicatedStorage.Clothingremote Fire:FireServer("Cloth1","Really red") end)
script in serverscriptservices
game.Players.PlayerAdded:Connect(function(plr) local Clone = game.ServerStorage["Cloth Gui"]:Clone() Clone.Parent = plr.PlayerGui end) game.ReplicatedStorage.Clothingremote.OnServerEvent:Connect(function(plr,Message,Color) if Message == "Cloth1" then plr.TeamColor = BrickColor.new(Color) end end)
also I made 3 team 1 team auto assignable 2 team unassignable.
What I do is make a value in the players character, and use it as a cool down, for example:
game.Players.PlayerAdded:Connect(function(plr) local Clone = game.ServerStorage["Cloth Gui"]:Clone() Clone.Parent = plr.PlayerGui local Cooldown = Instance.new("BoolValue") -- I don't know if I spelt this right, im just writing this. Cooldown.Parent = plr.Character Cooldown.Name = "ChillOut" end) game.ReplicatedStorage.Clothingremote.OnServerEvent:Connect(function(plr,Message,Color) if Message == "Cloth1" and plr.Character.ChillOut.Value == false then plr.Character.ChillOut.Value = true plr.TeamColor = BrickColor.new(Color) wait(1) plr.Character.ChillOut.Value = false end end)
Erm sorry if this is not helpful or good enough but at least I tried :P Basically we just make sure the ChillOut value is false before using it. Another way you could do this to prevent spamming is to detect how many times they have used it in the last minute ect
game.Players.PlayerAdded:Connect(function(plr) local Clone = game.ServerStorage["Cloth Gui"]:Clone() Clone.Parent = plr.PlayerGui local Cooldown = Instance.new("NumberValue") -- I don't know if I spelt this right, im just writing this. Cooldown.Parent = plr.Character Cooldown.Name = "ChillOut" end) game.ReplicatedStorage.Clothingremote.OnServerEvent:Connect(function(plr,Message,Color) if Message == "Cloth1" then plr.Character.ChillOut.Value = plr.Character.ChillOut.Value + 1 plr.TeamColor = BrickColor.new(Color) end end)
Or you could mix them both up. Eh I don't really know, most of the time I use the first way but edited with a little mix of the 2nd way.