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

Make this crawl animation have multiple parts?

I'm trying to make multiple parts to my crawl animation, these parts being:

  • Begin Animation (Get onto the ground)

  • Idle Animation

  • Crawl Animation (Main animation)

  • End Animation (Get up)

Issues:

  • Whenever the key "C" is held down, the player is meant to play the Begin Animation the animation does not play, as the Idle Animation plays instead.
  • The Idle Animation does play, but will not allow the Crawl Animation to play.
  • The Crawl Animation does not play as stated above.

The *End Animation plays fine, but after it plays it goes straight to the Begin Animation starting it all over again.

Script:

Note: This script was taken originally as a free model but was edited to play multiple animations.

Player = game.Players.LocalPlayer
repeat
  wait()
until Player.Character
Mouser = Player:GetMouse()
name = Player.Name
char = game.Workspace[Player.Name]

AnimationIdle = script.AnimIdle
Animation = script.Anim
Begin = script.GetDown
End = script.GetUp

idletrack = char.Humanoid:LoadAnimation(AnimationIdle)
begintrack = char.Humanoid:LoadAnimation(Begin)
animtrack = char.Humanoid:LoadAnimation(Animation)
endtrack = char.Humanoid:LoadAnimation(End)

 
Mouser.KeyDown:connect(function(key)
  if key == "c" and char.Humanoid.Running == true then
      char.Humanoid.WalkSpeed = 0
      begintrack:Play()
      wait(1)
      animtrack:Play()
      char.Humanoid.WalkSpeed = 4
      char.Humanoid.JumpPower = 0
  else
      if key == "c" then
          idletrack:Play()
      end
          end
      end)
  
  Mouser.KeyUp:connect(function(key)	
   if key == "c"  then
      char.Humanoid.WalkSpeed = 0
      animtrack:Stop()
      endtrack:Play()
      char.Humanoid.WalkSpeed = 16
      char.Humanoid.JumpPower = 50
  end
end)

Script Hierarchy

Game > StarterGui > Crawl > AnimIdle, Anim, GetDown, GetUp

Thank you in advance if you can help!

1 answer

I don't understand what are you want doing but try that

--< Services
local PlayerService = game:GetService('Players')
local UserInputService = game:GetService('UserInputService')

--< Variables
local Player = PlayerService.LocalPlayer
local name = Player.Name
repeat wait() until Player.Character
local char = Player.Character

local AnimationIdle = script.AnimIdle
local Animation = script.Anim
local Begin = script.GetDown
local End = script.GetUp

local idletrack = char.Humanoid:LoadAnimation(AnimationIdle)
local begintrack = char.Humanoid:LoadAnimation(Begin)
local animtrack = char.Humanoid:LoadAnimation(Animation)
local endtrack = char.Humanoid:LoadAnimation(End)

--< Events
UserInputService.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.C and char.Humanoid.Running == true then
		char.Humanoid.WalkSpeed = 0
		begintrack:Play()
		wait(1)
		animtrack:Play()
		char.Humanoid.WalkSpeed = 4
		char.Humanoid.JumpPower = 0
	elseif input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.C then
		idletrack:Play()
	end
end)

UserInputService.InputEnded:Connect(function(input)  
	if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.C then
		char.Humanoid.WalkSpeed = 0
		animtrack:Stop()
		endtrack:Play()
		char.Humanoid.WalkSpeed = 16
		char.Humanoid.JumpPower = 50
	end
end)

1 comment

0

Sorry if it wasn't clear enough, I'm trying to make it so when you hold C you'll start crawling, and if you don't move you'll be idle. But once you release C then the player will get up and stop crawling. But it glitches out and plays idle whenever you move, and when you try to get up it plays the animation but you go right back down. The same glitch happens with your script.

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