I am making this clicker game on Roblox. Everything is working fine except that when there are multiple people playing there is a lot of server lag and sometimes the clicking doesn't register.
When the button is clicked, it fires an event:
local leaderstats = game.Players.LocalPlayer:WaitForChild("leaderstats")
local button = script.Parent
button.MouseButton1Click:Connect(function()
game.Workspace.GetClickScript.GetClick:FireServer()
end)
And a server script detects the event fired and does this:
local debounce = false
script.GetClick.OnServerEvent:Connect(function(plr)
if not debounce then
debounce = true
local leaderstats = plr:WaitForChild("leaderstats")
leaderstats.Clicks.Value += 1
wait(0.2)
debounce = false
end
end)
Except it gets extremely slow when multiple players are clicking the button (because it is a server script). Is there a way to make it faster, or even make it a local script?
question from:
https://stackoverflow.com/questions/65890141/how-to-fix-server-lag-in-roblox 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…