So this is an obstacle course game and i am trying to make it so that every 20 stages you complete / gain in the statistics wise of course, you get +1 Skips in the stats place as well.
Stage = game.Players.LocalPlayer.PlayerStats:WaitForChild("Stage") Skips = game.Players.LocalPlayer.PlayerStats:WaitForChild("Skips") if Stage.Value >= 10 then Skips.Value = 1 elseif Stage.Value >= 20 then Skups.Value = 2 end
First of all, if the game is Filtering Enabled
then Local Scripts
really can't affect leaderstats of any kind. Also, this obviously won't do anything because the script only runs once, and doesn't get updated. To update the script, you could use a Loop or the Changed
event. I suggest the Changed event. I also suggest using a regular script, and getting the players with the PlayerAdded
event.
Example,
-- In a regular script in Server Script Service game.Players.PlayerAdded:connect(function(plr) local PlayerStats = plr:WaitForChild("PlayerStats") local Stage = PlayerStats:WaitForChild("Stage") local Skips = PlayerStats:WaitForChild("Skips") Stage.Changed:connect(function() if Stage.Value >= 10 then Skips.Value = 1 elseif Stage.Value >= 20 then Skips.Value = 2 end end) end)
All we have to do is divide Stage by 10 and use the math.floor
function to round it down.
-- In a regular script in Server Script Service game.Players.PlayerAdded:connect(function(plr) local PlayerStats = plr:WaitForChild("PlayerStats") local Stage = PlayerStats:WaitForChild("Stage") local Skips = PlayerStats:WaitForChild("Skips") Stage.Changed:connect(function() Skips.Value = math.floor(Stage.Value/10) end) end)
Good Luck!
Stage = game.Players.LocalPlayer.PlayerStats:WaitForChild("Stage") Skips = game.Players.LocalPlayer.PlayerStats:WaitForChild("Skips") if Stage.Value >= 10 then Skips.Value = 1 elseif Stage.Value >= 20 then Skips.Value = 2 end
You simply misspelled "Skips" in line 7. In your original code, you put "Skups".