What do you want to achieve?
I’m trying to make it so that each time player joins the game, there will be a chance of an new anim appearing for the npc instead of the main one.
What is the issue?
Everything works properly as planned (first anim works too), but last two anims, they for some reason show on the server only, not on the player’s screen
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried looking on the developer forum but didn’t found anything.
local animation = Instance.new("Animation")
animation.Parent = script
local random = math.random(1, 3)
task.wait(0.1)
print(random)
task.wait(0.1)
if random == 1 then
animation.AnimationId = "rbxassetid://9847473852"
local anim = game.Workspace.Dummy.Humanoid:LoadAnimation(animation)
anim.Looped = true
anim:Play()
elseif random == 2 then
animation.AnimationId = "rbxassetid://10321235458"
local anim = game.Workspace.Dummy.Humanoid:LoadAnimation(animation)
anim.Looped = true
anim:Play()
elseif random == 3 then
animation.AnimationId = "rbxassetid://10294280807"
local anim = game.Workspace.Dummy.Humanoid:LoadAnimation(animation)
anim.Looped = true
anim:Play()
end
It’s a single player game, sorry forgot to say that. The main problem is for some reason when i test it animation doesn’t show on mine screen, but pretty much does on the current server
If this is a one player game you should use a local script.
local animation = Instance.new("Animation")
animation.Parent = script
local function Animate(ID)
animation.AnimationId = ID
local anim = workspace.Dummy:LoadAnimation(animation)
anim.Looped = true
anim:Play()
end
local random = math.random(1, 3)
task.wait(0.1)
print(random)
task.wait(0.1)
if random == 1 then
Animate("rbxassetid://9847473852")
elseif random == 2 then
Animate("rbxassetid://10321235458")
elseif random == 3 then
Animate("rbxassetid://10294280807")
end