Help With a Script not playing Animation on FBX Model fully

Whenever I import an FBX Animation into studio and than script it to play in game only 3 seconds [about] of the actual animation plays and than loops back to the start and I am unsure how to fix this.

Heres the script im using:

local aim = script.Parent.AnimationController:LoadAnimation(script.Parent.Animation)

while true do
wait(3)
aim:play()
end

Anyone able to help. Also I wanted to know how to make the animation run off a clickdetector?

1 Like

Apparently changing wait to anything higher or lower makes the animation last longer but you gotta wait that amount of time first which Is strange to me.

Instead of using a while do loop to play in a loop, you can just change the animation loop property to true so you don’t have to use wait() to depend on the animation since the wait() function is not always accurate.

local aim = script.Parent.AnimationController:LoadAnimation(script.Parent.Animation)

aim.Looped = true 
aim:play()

For a click detector, which also can work in localscript, this script should be fixed by just simply making a function and connecting it.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.Character.CharacterAdded:Wait()
local anim = char.AnimationController:LoadAnimation(char.Animation)

local clickDetector = workspace.Part.ClickDetector
 
function onMouseClick()
	anim:Play()
end
 
clickDetector.MouseClick:connect(onMouseClick)
2 Likes

When I put this into a script it doesn’t do any animations when I click

The clickDetector script is added into a LocalScript.