Why isn't my animation playing?

I made a boss health bar that triggers based on a bindable event, and everything works, but the animation isn’t being played, and so far I can’t find the reason for why it doesn’t play.

This is the script below the screen gui that has the healthbar, it works based on an object value:

workspace.Bosstime.Event:Connect(function(guy,id,speed)
	local bar = script.Parent:Clone()
	bar.Parent = script.Parent.Parent
	bar.Enabled = true
	bar.Boss.Value = guy --sets the objectvalue to the boss
	wait(0.1)
	bar.Frame.Bar.HealthbarScript.Enabled = true
	bar.Frame.Bar.NameScript.Enabled = true
	local prev = guy:Clone()
	prev.Parent = bar.Frame.ViewportFrame
	prev.HumanoidRootPart.Anchored = true
	local viewportCamera = Instance.new("Camera")
	bar.Frame.ViewportFrame.CurrentCamera = viewportCamera
	viewportCamera.Parent = bar.Frame.ViewportFrame
	viewportCamera.CFrame = CFrame.new(prev.Head.Position+prev.Head.CFrame.LookVector*6, prev.Head.Position)
	wait(1)
	local anim = Instance.new("Animation")
	anim.Parent = prev
	anim.AnimationId = "http://www.roblox.com/asset/?id=" .. id
	local hum = prev:FindFirstChildOfClass("Humanoid")
	local dance = hum:LoadAnimation(anim)
	dance:Play()
	dance:AdjustSpeed(speed)
end)

Is this a server script? Also, can u show us the whole script

yes it’s a server script, but despite that it works perfectly, and also that’s the whole script, the only thing that doesn’t work is the animation playing

Where did you set your id variable?

Also, I think you should change UI client side and use events for server to client communication.

this is the test script with which i’m testing the health bar’s functionality:

local mobgroup = workspace.Mobs
local mobstore = game.ServerStorage.Mobs

wait(5)
	local spawnPos = Vector3.new(math.random(-170,30), 16, math.random(-838,-570)) --Current Position (Spawner)
	local pos = spawnPos --Extra Stoff, don't touch
	local noob1 = game.ServerStorage.Mobs["Mace Dude"]:clone() --Cloning
	noob1.Parent = mobgroup --Parent
	noob1:MoveTo(pos) --Spawn Values (X, Y, Z)
	--You can also use Math.Random() to calculate your spawns to a random set of values for the Vector3.new() Values
    workspace.Bosstime:Fire(noob1,15302502145,0.5)
    workspace.Boss:Play()
	game.Lighting.ColorCore.Saturation = 4
	workspace.Camera.FieldOfView = 110
	for i = 1,40 do
		wait(0.1)
	game.Lighting.ColorCore.Saturation = game.Lighting.ColorCore.Saturation - 0.1
	workspace.Camera.FieldOfView = workspace.Camera.FieldOfView - 1
	end

repeat
	task.wait(1)
until #mobgroup:GetChildren() <1

print("WAVE ENDED")
workspace.Wave.Value = workspace.Wave.Value + 1
task.wait(1)
script.Parent.WAVE5.Disabled = true
script.Parent.WAVE6.Disabled = false

Turns out the problem was that I didn’t have a worldmodel. My bad for bothering everyone today. Have a nice day.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.