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

Why is the animation broken and not working? What am I doing wrong?

warn("Loading... ")
wait(0.025)
warn("Loaded!... ")

local anim = script.Punch

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char.Humanoid

script.Parent.Activated:Connect(function()
     local animloaded = hum:LoadAnimation(anim)
     animloaded:Play()

-- im tired please help

     

1 comment

0

This is a local script; that is placed in the StarterPack

1 answer

Try This:

warn("Loading... ")
wait(0.025)
warn("Loaded!... ")

local Anim = script:WaitForChild("Punch",10) --Crash Reason???

local Plr = game:GetService("Players").LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local Hum = char.Humanoid

script.Parent.Activated:Connect(function()
     local AnimLoaded = Hum.Animator:LoadAnimation(Anim) --hum:LoadAnimation is Decipricated so you refer to the animator instead
     AnimLoaded:Play()
end)

Put WaitForChild when trying to find the animation, because as soon as studio starts, it needs time to load

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