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

How do I change this script to stop playing animation after Q is clicked second time?

Asked by 5 years ago

Having troubles with this script. It makes my animation play when I press Q, but not to stop once I press Q again. The "script.Sitting.Value" already changes to true and false when you press, I checked that already and that's not the issue.

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?id=3344732901"

local Player = game.Players.LocalPlayer
local Mouse =  Player:GetMouse()
local animTrack = nil
Mouse.KeyDown:connect(function(key)
    if key:lower() == "q" then
        local character = Player.Character
        animTrack = character:WaitForChild("Humanoid"):LoadAnimation(animation)
        if script.Sitting.Value == false then
        animTrack:Play()
        else animTrack:Stop()


    end

    end
end)
0
Is this a local script or a server script? DreamInspired 61 — 5y
0
Local script. tim458458 29 — 5y

Answer this question