Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

intvalue's integer wont decrease in value when boolvalue is set to true?

Asked by 1 year ago

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
Is the other script a Local Script? Because it won't work if it's a Local Script. T3_MasterGamer 2189 — 1y

Answer this question