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

A boolean value of a variable is not changing, help?

Asked by 5 years ago

I've created a simple stamina bar with a simple script, it is not done yet but the problem is the value is not changing.

Variables

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid
local over = script.Parent.Overlay
local under = script.Parent
local stamina = 100
local maxStamina = 100
local humanoidJump = false

-- Functions

function update()
    local staminaScale = stamina / maxStamina
    over:TweenSize(UDim2.new(staminaScale,0,1,0), "In", "Linear", 0.1)
    wait(0.1)
    print("Test")
end

-- Code Execution

if stamina < 100 then
    update()
end

if humanoidJump == true then --This area is where the stamina changes
    print("Test")
    stamina = 25 - stamina
elseif humanoidJump == false and stamina < 100 then
    stamina = 10 + stamina
end

game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.Space then
        humanoidJump = true --This area seemed to contain the problem
    wait(0.5)
    humanoidJump = false
    print("test")
    end 
end)
0
Lines 23-32 will only run once when the server initiates. Try putting that part of code inside a while loop. Don't forget a wait() xPolarium 1388 — 5y
0
I'll try that out, thanks for your recommendation. Klarner 0 — 5y

Answer this question