Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

1 comment

0

connect is deprecated so use Connect

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.