#The stamina script won't disable nor will the colour change

4 messages · Page 1 of 1 (latest)

celest pivot
#

Basically I want it so when this tool is used, it increases the player speed and disables the stamina. The speed is changing correctly but the stamina won't change, this is a problem because normall when you press shift it changes the player's walkspeed, so if the stamina is still on then that means when they press sprint, the walk speed increase from the heal won't work anymore.

Hopefully i explained that ok

#

This is the full code

#
Tool = script.Parent

local field = nil

function Heal()
    Tool.Handle.Weld:remove()
    local vCharacter = Tool.Parent
    local childs = vCharacter:GetChildren()
    local colors = {}
    for i=1,#childs do
        if (childs[i].className == "Part") then
            colors[i] = childs[i].BrickColor
        end
    end
    wait(0.5)
    Tool.Liquid:remove()
    Tool.Cork:remove()
    local human = vCharacter:FindFirstChild("Humanoid")
    local Stamina = game.StarterGui.StaminaGui
    if (human ~= nil) then
        human.WalkSpeed = 36
        Stamina.Handler.Disabled = true
        Stamina.Holder.Bar.BackgroundColor = Color3.new(0.984314, 1, 0.113725)
        local effects = script.Hearts:clone()
        effects.Parent = vCharacter.Head
        effects.Enabled = true
        effects.EffectScript.Disabled = false
        wait(3)
        human.WalkSpeed = 16
        Stamina.Handler.Disabled = false
        Stamina.Holder.Bar.BackgroundColor = Color3.new(18, 255, 6)
    end
    for i=1,#childs do
        if (childs[i].className == "Part") then
            childs[i].BrickColor = colors[i]
        end
    end
end

Tool.Enabled = true

function onActivated()
    if not Tool.Enabled then
        return
    end
    Tool.Enabled = false
    Heal()
    wait(0.75)
    local Bottle = Tool.Handle:clone()
    Bottle.CanCollide = true
    Bottle.Parent = game.Workspace
    Bottle.CFrame = CFrame.new(Tool.Handle.Position)
    Tool.Parent = nil
    local debris = game:GetService("Debris")
    debris:AddItem(Bottle,3)
end

script.Parent.Activated:connect(onActivated)
#

not sure if this helps but it's a normal script inside the tool in workspace