local player = game.Players:GetPlayerFromCharacter(script.Parent)
print("test1")
local energy = player:WaitForChild("Energy")
print("test2")
energy.Changed:Connect(function() --waits for the value to be changed
print("test3")
if energy.Value <= 15 then --checks if the val is lower than 15
print("test4")
player.Character.Humanoid.WalkSpeed = 5
else
print("test5")
player.Character.Humanoid.WalkSpeed = 14
end
print("test6")
if energy.Value <0 then
print("test7")
energy.Value = 0
end
end)
This script is inside the starterplayerscripts. It prints test 1 and 2 when I start the game but whenever I change the value (energy is a NumberValue) it doesnt fire at all.
Thats because when you change it in studio you change it on the client side, and seeing this is a script (ran on the server) the script doesn’t see any change.
Basically the client is the stuff loaded on the player’s pc, local scripts are also ran on the client
Server is just normal scripts and any change gets replicated to every client in game, but stuff that you change on the client (like youre doing now) doesn’t replicate to the server so the server can’t see it.
Basically just change this to become the server and then change it so the script can fire the .Changed event