Why wont int value change

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

Im making speed simulator and when you walk your speed gets 0.1 more

  1. What is the issue? Include screenshots / videos if possible!

when defining it it wont change even though it passes all checks

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

yes i tried but didnt find why this wouldnt work

Server Script

while task.wait() do
	for _, v in next, game:GetService("Players"):GetPlayers() do
		if v:FindFirstChild("leaderstats") and v.leaderstats:FindFirstChild("Speed") and v.Character then
			local hum = v.Character:FindFirstChildOfClass("Humanoid")
			if hum and hum.MoveDirection ~= Vector3.new(0, 0, 0) then
				v.leaderstats.Speed.Value += 0.1
			end
		end
	end
end

Try using ipairs() instead of next, as you are going through an array of players and not a dictionary.

I tried it but it didnt work,

and also im pretty sure next works on dictionaries and tables etc.

Can I please see your updated code?

while task.wait() do
	for _, v in ipairs(game:GetService("Players"):GetPlayers()) do
		if v:FindFirstChild("leaderstats") and v.leaderstats:FindFirstChild("Speed") and v.Character then
			local hum = v.Character:FindFirstChildOfClass("Humanoid")
			if hum and hum.MoveDirection ~= Vector3.new(0, 0, 0) then
				v.leaderstats.Speed.Value += 0.1
			end
		end
	end
end

IntValues only work with integers (whole numbers). They automatically round up or down when given a decimal. Change it to a NumberValue instead. NumberValues will take numbers with decimals.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.