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)
The code you gave us doesn't seem relevant to your error. That message looks to be due to an error occurring in the ScriptContext.Error
event (and I don't think you would get that error under any other circumstances.)
To fix this issue, you're going to have to track down wherever you used ScriptContext.Error
and make sure that you don't have any erroneous code.
Let me know if this helps any!
Right, Don't use Enabled
as it is unreliable. Instead, keep going with the cooldown.
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)
I see nothing wrong this code.