Need help with animation script

what i want to do: trying to make animation appear once i press q

what i did so far:

local uis = game:GetService(“UserInputService”)
local Animazon = script.Animazon

local player= game.Players.LocalPlayer

local char = player.Character

local hum = char.Humanoid

uis.InputBegan:Connect(function(Input)

if Input.KeyCode == Enum.KeyCode.Q then
	wait(1)
local Animazon = hum:LoadAnimation(Animazon)
	
end

end)

Animazon:Play()

I’ve also place a local script in startercharacter if its wrong please say so
this is what the output says
Animazon is not a valid member of LocalScript “Workspace.butter5432m.AnimationHandler”

It’s because it takes some extra time for the components to load / be parented. Use Instance:WaitForChild instead and the issue should be gone.

1 Like
local uis = game:GetService(“UserInputService”)
local Animazon = script.Animazon

local player= game.Players.LocalPlayer

local char = player.Character

local hum = char.Humanoid

uis.InputBegan:Connect(function(Input)

if Input.KeyCode == Enum.KeyCode.Q then
	wait(1)
local Animazon = hum:LoadAnimation(Animazon)
	
end
end)

Animazon:Play()

Change “local Animazon” to “ local Animazon = script:WaitForChild("Animazon")”.

1 Like
local uis = game:GetService("UserInputService")
local players = game:GetService("Players")
players.PlayerAdded:wait()
local player = players.LocalPlayer
player.CharacterAdded:wait()
local char = player.Character
local hum = char:WaitForChild("Humanoid")
local Animazon = script:WaitForChild("Animazon")

uis.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.Q then
		wait(0.5)
		local Animazon = hum:LoadAnimation(Animazon)
		wait(0.5)
		Animazon:Play()
	end
end)
1 Like