Let’s start off with the problem. I have towers for a tower defense game (like it should) and I have added animations to them. They seem to work perfectly fine in studio when I test it but if I join the actual game, they don’t load.
Video
Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local events = ReplicatedStorage:WaitForChild("events")
local tower_animate = events:WaitForChild("tower_animate")
local function set_anim(object, animName)
local humanoid = object:WaitForChild("Humanoid")
local anim_folder = object:WaitForChild("Animations")
if humanoid and anim_folder then
local anim_object = anim_folder:WaitForChild(animName)
if anim_object then
local animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator", humanoid)
local playing_tracks = animator:GetPlayingAnimationTracks()
for i,track in pairs(playing_tracks) do
if track.Name == animName then
return track
end
end
local anim_track = animator:LoadAnimation(anim_object)
return anim_track
end
end
end
local function play_anim(object, animName)
local anim_track = set_anim(object, animName)
if anim_track then
anim_track:Play()
else
warn("Anim unavailable")
return
end
end
workspace.placed_towers.ChildAdded:Connect(function(object)
play_anim(object, "Idle")
end)
tower_animate.OnClientEvent:Connect(function(tower, anim_name)
play_anim(tower, anim_name)
end)
Yes, the anims are published in a group.
There are no errors shown in the output.