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

How would I add wait(3) and make enabled=false?

Asked by 8 years ago

When the player clicks, the part is supposed to go to the player's mouth for only a few seconds. How would I make it wait(3) and then enabled=false? Also what line should I put the line of script on? Thank you.

local Tool = script.Parent;

enabled = true




function onActivated()
    if not enabled  then
        return
    end

    enabled = false
    Tool.GripForward = Vector3.new(-0.976,0,-0.217)
    Tool.GripPos = Vector3.new(.95,-0.76,1.4)
    Tool.GripRight = Vector3.new(0.217,0, 0.976)
    Tool.GripUp = Vector3.new(0,1,0)


    Tool.Handle.DrinkSound:Play()

    wait(.8)

    local h = Tool.Parent:FindFirstChild("Humanoid")
    if (h ~= nil) then
        if (h.MaxHealth > h.Health + 1.6) then
            h.Health = h.Health + 1.6
        else    
            h.Health = h.MaxHealth
        end
    end

    Tool.GripForward = Vector3.new(-0.976,0,-0.217)
    Tool.GripPos = Vector3.new(0.3,0,0)
    Tool.GripRight = Vector3.new(0.217,0,-0.976)
    Tool.GripUp = Vector3.new(0,1,0)


    enabled = true

end

function onEquipped()
    Tool.Handle.OpenSound:play()
end

script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)

Answer this question