Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Gain 1 XP for every 5 Steps, but want to be able to go up by more than just 5 at a time?

Asked by 5 years ago

I want to make it for every 5 steps a player takes, they will gain XP.. but there will also be ways to gain things such as "+150 steps", but it won't reward them with 30 XP. I know that this is not the best way to do it, so I'm wondering what other ways I can do it.

I can always do something with the player's last checked step count but not sure.

s.Steps.Changed:connect(function()
    if s.Steps.Value/5 == math.floor(s.Steps.Value/5) then
        s.XP.Value = s.XP.Value+1
    end
end)
0
connect is deprecated so use Connect User#19524 175 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

You just need to make a separate variable for the needed steps and the xp awarded.

neededsteps = 5
xpawarded = 1
s.Steps.Changed:Connect(function() -- connect is deprecated so use Connect
    if s.Steps.Value/neededsteps == math.floor(s.Steps.Value/neededsteps) then
        s.XP.Value = s.XP.Value+xpawarded
    neededsteps = neededsteps + 5 -- You could change how much this goes up or make a multiplier
    xpawarded = xpawarded + 1 -- same thing as above
    end
end)
Ad

Answer this question