I would like to make this script about giving strength even faster to achieve so people wouldn't have to wait so much. I can only put a wait() script, but how can I remove it and not make this script wait in 0 seconds? (local script)
local savedStrengthValue = 0 local strengthValue = 0 script.Parent.MouseButton1Click:Connect(function() savedStrengthValue = tonumber(script.Parent.StrengthVal.Text) strengthValue = strengthValue + savedStrengthValue repeat game.ReplicatedStorage.remotes.lifts.CustomLift:FireServer(game.Players.LocalPlayer) strengthValue = strengthValue - 1 wait() until strengthValue == 0 end)
Please fix this.
-- Server game.ReplicatedStorage.remote.lifts.CustomLift.OnServerEvent:Connect(function(player, val) -- make the server side increment the strength value by val isntead of just 1 end) -- Client local savedStrengthValue = 0 local strengthValue = 0 script.Parent.MouseButton1Click:Connect(function() savedStrengthValue = tonumber(script.Parent.StrengthVal.Text) strengthValue = strengthValue + savedStrengthValue game.ReplicatedStorage.remotes.lifts.CustomLift:FireServer(strengthValue) end)
As a side note, this is very insecure way to approach this problem. Players could send requests to their server by spoofing remove event invokes. Consider a different method. :)
I noticed that the first variable in a RemoteEvent does not work. Here is how I would fix this:
--Client local savedStrengthValue = 0 script.Parent.MouseButton1Click:Connect(function() savedStrengthValue = tonumber(script.Parent.StrengthVal.Text) game.ReplicatedStorage.remotes.lifts.CustomLift:FireServer(game.Players.LocalPlayer,savedstrengthValue) end) --Server game.ReplicatedStorage.remote.lifts.CustomLift.OnServerEvent:Connect(function(a,player, val) player.leaderstats.Strength.Value = player.leaderstats.Strength.Value + val end)
I was supposed to add an "a" behind the "player" variable, but I don't know why.