Hi! I’m having some trouble running an animation on a part. All I’m trying to do is tween the container part, load an animation into the container, and play it. The following code is inside a server script:
local foodRemote = game.ReplicatedStorage.RemoteEvents.DetectFoodEat
local click = script.Parent.ClickDetector
local TweenS = game:GetService("TweenService")
click.MouseClick:Connect(function(player)
-- Food variable is temporarily hard-coded for testing purposes
local food = game.Workspace["Food System"].Workspace.Table.Placemats.Mat.TinySide.FruitCrumble
local char = player.Character
local hum = char:WaitForChild("Humanoid")
local container = food.Container
container.Anchored = true
local foodAttach = char.Torso:WaitForChild("FoodAttach")
local newInfo = TweenInfo.new(
2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.In)
local foodTween = TweenS:Create(container,newInfo,{
CFrame = CFrame.new(foodAttach.WorldPosition,foodAttach.WorldAxis)
})
foodTween:Play()
foodTween.Completed:Wait()
local foodClone = food:Clone()
foodClone.Parent = player.Character
foodClone.Name = "AnimFood"
local cloneContainer = foodClone.Container
local animation = Instance.new("Animation")
-- The animation id is set to the correct animation in the real script
animation.AnimationId = "rbxassetid://0000000000"
local controller = Instance.new("AnimationController",cloneContainer)
local containerTrack = controller:LoadAnimation(animation)
containerTrack:Play()
foodRemote:FireClient(player,foodClone)
end)
There are no errors in the output, and all the variables seem to be correct. The tweeting is working fine, the food model is being cloned, and the AnimationController is being created, but the animation is never playing on the client or on the server.
The food remote event is firing, but I’ve commented out everything there for testing purposes, so that’s not interfering at all.
Any assistance would be greatly appreciated!