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

How can i make the animation play in local script?

i want the animation to play when i press E key

heres the local script

local plr = game.Players.LocalPlayer


local Player = game.Players.LocalPlayer

local UserInputService = game:GetService("UserInputService")

local Character = Player.Character or script.Parent




local key = 'E'
local debounce = true

UserInputService.InputBegan:Connect(function(Input, IsTyping)

if  IsTyping then return end


if Input.KeyCode == Enum.KeyCode[key] and debounce == true then
	debounce = false
	local Animation = Instance.new("Animation")
	local Humanoid = Character.Humanoid


		

		local player = game:GetService("Players").LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local RootPart = Character.HumanoidRootPart
plr.Character.Humanoid.WalkSpeed = 0

local BV = Instance.new("BodyVelocity")
  BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Velocity = RootPart.CFrame.lookVector.Unit * 65 

BV.Parent = RootPart
wait(1)



BV:Destroy()
	

	debounce = true
		plr.Character.Humanoid.WalkSpeed = 16

		wait(2)
	end
end)

1 answer

Put this code in line 25.

local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://YOURIDHERE"
local AnimationTrack = Humanoid:LoadAnimation(Animation)
AnimationTrack:Play()

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