local fuel = game.ReplicatedStorage.Fuel.Value
local fuelLoss
game.ReplicatedStorage.Fuel:GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.Humanoid.WalkSpeed = fuel/37.5
script.Parent.LowerTorso.Fire.Size = fuel/60
script.Parent.UpperTorso.PointLight.Range = fuel/30
fuelLoss = 1/(2^(fuel/300))
wait(fuelLoss)
fuel = fuel - 1
end)
if fuel == 0 then
script.Parent.Humanoid.Health = 0
end
Which is suppose to take the value of the player a make an operation. We wait the result, then remove 1 to the value, and repeat, problem is that value stored in RS doesn’t change. Why?
On the first line, you grab the .Value of fuel. This means that the fuel variable now contains the Value of the Fuel compared to the Fuel object. It would need to be game.ReplicatedStorage.Fuel I believe.
It seems that the problem come from the
fuel.Changed:Connect(function()
Line.
For some reasons, I think it doesn’t detect the value change (I just want to precise that I’m using IntValue)
local replicatedStorage = game:GetService("ReplicatedStorage") -- sometimes getting the service makes it work
local fuel = replicatedStorage.Fuel -- don't get the Fuel.Value, it doesn't work
While setting a local variable from a global one, it won’t work if you get only the Value. (See my second line of script)
It should work with these changes. I hope it will !
Another thing that might be the problem:
Make the script wait before changing the value of Fuel. Maybe it’s changing before the other script being ready.
Everything is handled by the same script, so I don’t see why there should be a priority with this script. When the script is loaded, it remove 1 to the fuel value and then it should make the loop. The problem come from the changing value detection
Computers still need to read things before they can do what you tell them to.
Here, you’re changing the value before the computer knows that he needs to do something if the value is changed.
You need to put this line after your function:
fuel.Value = fuel.Value - 1
If you do this, the computer will know that there is a function connected if this value is changed. Otherwise it doesn’t and thus doesn’t fire the function (because it doesn’t know it exists yet).