TapsoNNN
(TapsoNNN)
January 21, 2021, 1:23pm
#1
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)
heII_ish
(heII_ish)
January 21, 2021, 1:24pm
#2
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
TapsoNNN
(TapsoNNN)
January 21, 2021, 1:26pm
#3
didnt help now the value stays on 1
LiamKyd
(JohnWick)
January 21, 2021, 1:27pm
#4
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
heII_ish
(heII_ish)
January 21, 2021, 1:28pm
#5
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)
TapsoNNN
(TapsoNNN)
January 21, 2021, 1:29pm
#7
arleady did that no errors the value do not change now it stays on 1
TapsoNNN
(TapsoNNN)
January 21, 2021, 1:30pm
#8
Thats not the problem script finds the object but do not update the value even though the server script
heII_ish
(heII_ish)
January 21, 2021, 1:30pm
#9
What type of value is it? IntValue? NumberValue?
TapsoNNN
(TapsoNNN)
January 21, 2021, 1:31pm
#10
heII_ish:
IntValue
it is a IntValue
--Leaderstats
SPower = Instance.new("IntValue")
SPower.Name = "Power"
heII_ish
(heII_ish)
January 21, 2021, 1:32pm
#11
IntValues only accept whole numbers without decimals. eg: 1, 2, 3, 4, 5
Try changing it to a NumberValue
1 Like
TapsoNNN
(TapsoNNN)
January 21, 2021, 1:34pm
#13
thanks it works now
the NumberValue solved the Problem