Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Infinite yield possible? Script not working for animating a tool.

Asked by 5 years ago

Whenever I try to click one it wont play the animation and two in the output it says:

Infinite yield possible. "local AnimationController = AnimGun:WaitForChild("AC")

The script is here:

--Gun is the part of the gun that contains: Handle, Values and Scripts
local Gun = script.Parent
Gun.Equipped:Connect(function(mouse)
--AnimGun is a model because its a Rig, So it can be animated
local AnimGun = Gun:WaitForChild("MovingParts")

--Fake Handle (used in animation)
local FHandle = AnimGun:WaitForChild("FakeHandle")
--Real Handle (Used to hold tool)
local RHandle = Gun:WaitForChild("Handle")
--Make a table of the elements in MovingParts
local guntable = AnimGun:GetChildren()

--Make a weld from Real to Fake handle, parent weld to Real Handle
local HandleWeld = Instance.new("Weld",RHandle)
HandleWeld.Part0 = RHandle
HandleWeld.C0 = RHandle.CFrame:inverse()
HandleWeld.Part1 = FHandle
HandleWeld.C1 = FHandle.CFrame:inverse()

--Animating Part

local AnimationController = AnimGun:WaitForChild("AC") --Equivilent to Humanoid, instead used for animating NPCs
local Animation = Instance.new("Animation")
Animation.AnimationId = "https://www.roblox.com/Asset?ID=2157386862" --Put the animation ID here
local LoadAnimation = AnimationController:LoadAnimation(Animation) --Loads the Animation
print("Loaded the Animation")
mouse.Button1Down:connect(function()
        LoadAnimation:Play() --Plays the animation
        print("Animation played")
end)
end)

While I have tried adding something like this:

local AnimationController = AnimGun:WaitForChild("AC", 100)

It still doesn't work because the animation doesn't play.

0
There is no child named 'AC' in the AnimGun CPF2 406 — 5y
0
Oh right I'm stupid. Thanks. oshawat00 62 — 5y

Answer this question