I'm trying to make an energy system for sprint in my game, where if the player is sprinting it decreases the intvalue's integer value, however it doesn't seem to decrease when the boolvalue is set to true
When the player sprints the boolvalue is set to true and it should decrease the intvalues integer value, the boolvalue is set to true in another script
local player = game:GetService("Players")
player.PlayerAdded:Connect(function(plr)
local energy = Instance.new("IntValue", plr)
local sprinting = Instance.new("BoolValue", plr)
sprinting.Name = "Sprint"
energy.Name = "Energy"
plr.CharacterAdded:Connect(function(char)
energy.Value = 100
while char.Humanoid.Health > 0 do
if sprinting.Value == true then
energy.Value -= 1
end
wait(1)
end
end)
end)

1 comment
Is the other script a Local Script? Because it won't work if it's a Local Script.