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

I need help,my script is not working the way I want because it's movement isn't working right?

Asked by 6 years ago

So I am trying to make a game, but that game requires a crawl animation. I made a bad crawling animation for script testing purposes but if I stand still and activate my script, my animation starts, but if I move, it stop. vise versa, if I move while activating it, it will play my animation while I'm moving and if I stop moving, then my animation stops. So what I want is to start the animation with c, then it will go forever, regardless whether I move or not and when I start the animation, then when I press either x or c, it will stop. Please leave anything you think might work. (here's the script, I'm just starting scripting, the script is in between the lines)


local animation = Instance.new("Animation")

animation.AnimationId = "https://www.roblox.com/Asset?ID=01473278473"

local trackanimation = nil local playability = true local isCrawling = false

function onKeyPress(actionName, userInputState, inputObject)

    if userInputState == Enum.UserInputState.Begin then             
        if playability == true then
            local plr = game.Players.LocalPlayer
            trackanimation = plr.Character.Humanoid:LoadAnimation(animation)
            trackanimation.KeyframeReached:connect(function(kf)

        end)
        trackanimation:Play()

        end
    end
end

game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.C)


0
It's weird but that entire separated text is the script, even though they made it weird. HairBrain 0 — 6y
0
there is an edit button btw, you can edit the mistake. CrazyTwinkle -1 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
--Little tip, you don't need to check if a boolean value as you did, you can simply do the following..

if playability then
    -- do the following, no need to do "==true"
end
Ad

Answer this question