Value do not change

my goal:
by clicking on addPowerButton the Value of Power should be increased by 0.01

the Problem is that the Power Value stays on 1.01
(start value of power is 1)

EventPower.OnServerEvent:Connect(function(plr)
	local power = Players:WaitForChild((plr.Name)):WaitForChild("Skills"):WaitForChild("Power").Value
	power = power + 0.01
	print(power)
end)

You’re adding 0.01 to the reference of the old Value stored in a variable.

You should do

local power = Players:WaitForChild((plr.Name)):WaitForChild("Skills"):WaitForChild("Power")
power.Value = power.Value + 0.01
1 Like

didnt help now the value stays on 1

try to find the object and then set the value for it.

local object = player:FindFirstChild("something")

if object then
   object.Value += 0.1
end

Print the value after it’s set, and are there any errors in the output?

Any errors? I noticed you had two () around the plr.Name part. Also @hell_ish is right that you need to add an integer to an int value.

EventPower.OnServerEvent:Connect(function(plr)
	local power = plr:WaitForChild("Skills"):WaitForChild("Power")
	power.Value += 1
	print(power)
end)

arleady did that no errors the value do not change now it stays on 1

Thats not the problem script finds the object but do not update the value even though the server script

What type of value is it? IntValue? NumberValue?

it is a IntValue

--Leaderstats
SPower = Instance.new("IntValue")
	SPower.Name = "Power"

IntValues only accept whole numbers without decimals. eg: 1, 2, 3, 4, 5

Try changing it to a NumberValue

1 Like

thanks it works now :smiley:

the NumberValue solved the Problem