我正在 Roblox 上制作这款答题器游戏。一切正常,除了当有多个人玩时,服务器延迟很多,有时点击不注册。
单击按钮时,它会触发一个事件:
local leaderstats = game.Players.LocalPlayer:WaitForChild("leaderstats")
local button = script.Parent
button.MouseButton1Click:Connect(function()
game.Workspace.GetClickScript.GetClick:FireServer()
end)
服务器脚本检测到触发的事件并执行以下操作:
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)
除了当多个玩家点击按钮时它变得非常慢(因为它是一个服务器脚本)。有没有办法让它更快,甚至使它成为本地脚本?