I am making a simulator but when I click with the sword it freezes and crashes the game.
The script:
script.AddSlash.OnServerEvent:Connect(function(player)
player.leaderstats.Slashes.Value = player.leaderstats.Slashes.Value +1
end)
script.AddXP.OnServerEvent:Connect(function(player)
player.leaderstats.EXP.Value = player.leaderstats.EXP.Value +1
end)
Other Script:
local cooldown = false
script.Parent.Activated:Connect(function()
if cooldown == false then
cooldown = true
game.Workspace.MainEvent2.AddSlash:FireServer()
wait(0.5)
cooldown = false
end
end)

3 comments
Use Code Block.
do you have any .Changed code?
You have a while loop without a wait. To figure out where it is, press Ctrl+Shift+F (or Cmd+Shift+F) then type "while"