repeat wait() until game:IsLoaded()
local runService = game:GetService("RunService")
local debris = game:GetService("Debris")
local anim = game.Workspace.Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
anim.Looped = true
anim:Play()
runService.RenderStepped:Connect(function()
local stuff = game.Workspace.Interviewer:Clone()
for i, v in pairs(stuff:GetChildren()) do
if v:IsA("Part") or v:IsA("MeshPart") then
v.Anchored = true
end
end
stuff.Parent = script.Parent
debris:AddItem(stuff, 0.001)
end)
game.ReplicatedStorage.Events.LoadAnimation.OnClientEvent:Connect(function()
anim:Stop()
script.IdleAnim.AnimationId = 'rbxassetid://' .. 4940602656
anim:Play()
end)
why isn’t my animation changing when i fire the event?
You need to remake the animation. Animations are loaded onto the character and the character plays the animations. You cannot “remove” and animation from a Humanoid only stop it. So you have to make two animations at the start and then start and stop the relevant ones.
Instead do
--At the start of the script
local anim = game.Workspace.Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
script.IdleAdnim.AnimationId = -- Insert the other animation Id now
local anim2 = game.Workspace.Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
anim1:Play()
-- Then in the function
anim1:Stop()
anim2:Play()
All I get is a standing character with no animations:
Here is the script based on your suggestions:
repeat wait() until game:IsLoaded()
local runService = game:GetService("RunService")
local debris = game:GetService("Debris")
local anim = game.Workspace.Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
anim.Looped = true
anim:Play()
local waveanim = game.Workspace.Interviewer.Humanoid:LoadAnimation(script.WaveAnim)
game.ReplicatedStorage.Events.LoadAnimation.OnClientEvent:Connect(function()
anim:Stop()
waveanim.Looped = true
waveanim:Play()
end)
runService.RenderStepped:Connect(function()
local stuff = game.Workspace.Interviewer:Clone()
for i, v in pairs(stuff:GetChildren()) do
if v:IsA("Part") or v:IsA("MeshPart") then
v.Anchored = true
end
end
stuff.Parent = script.Parent
debris:AddItem(stuff, 0.001)
end)
repeat
wait()
until game:IsLoaded()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Debris = game:GetService("Debris")
local Interviewer = workspace.Interviewer
local IdleAnimation = Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
IdleAnimation.Looped = true
IdleAnimation:Play()
ReplicatedStorage.Events.LoadAnimation.OnClientEvent:Connect(function()
print("Restarting Animation", IdleAnimation) -- For Debugging.
IdleAnimation:Stop()
script.IdleAnim.AnimationId = "rbxassetid://4940602656"
local IdleAnimation = Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
IdleAnimation.Looped = true
IdleAnimation:Play()
end)
RunService.RenderStepped:Connect(function()
local Stuff = Interviewer:Clone()
for _, Object in pairs(Stuff:GetChildren()) do
if Object:IsA("Part") or Object:IsA("MeshPart") then
Object.Anchored = true
end
end
Stuff.Parent = script.Parent
Debris:AddItem(Stuff, 0.001)
end)
Are you sure this ID exists? If this was taken from the Asset ID URL, then there is a high possibility when moving to rbxassetid:// the id link won’t match up! This is a weird thing with ROBLOX, so to make sure, take your full animation with rbxassetid://4940602656 and try loading it in on a dummy.
repeat
wait()
until game:IsLoaded()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Debris = game:GetService("Debris")
local Interviewer = workspace.Interviewer
local IdleAnimation = Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
IdleAnimation.Looped = true
IdleAnimation:Play()
ReplicatedStorage.Events.LoadAnimation.OnClientEvent:Connect(function()
print("Restarting Animation", IdleAnimation) -- For Debugging.
IdleAnimation:Stop()
script.IdleAnim.AnimationId = "rbxassetid://4940564896"
local IdleAnimation = Interviewer.Humanoid:LoadAnimation(script.IdleAnim)
IdleAnimation.Looped = true
IdleAnimation:Play()
end)
RunService.RenderStepped:Connect(function()
local Stuff = Interviewer:Clone()
for _, Object in pairs(Stuff:GetChildren()) do
if Object:IsA("Part") or Object:IsA("MeshPart") then
Object.Anchored = true
end
end
Stuff.Parent = script.Parent
Debris:AddItem(Stuff, 0.001)
end)
Oh my god! Thanks so much for the help, I’ve been struggling with this for so long! Credits to @Hylician for his contribution too. Keep up the good work fellas!