Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)


2 comments

0

It's weird but that entire separated text is the script, even though they made it weird.

0

there is an edit button btw, you can edit the mistake.

1 answer

--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

This discussion is preserved as it was. New answers, comments, and votes are closed.