I am trying to make the local player do a default dance, and it worked (mostly) , but either sometimes it wouldn't work, or it would only work for a couple seconds, so I added a loop, but that does not work either, because it is too fast of a loop and I do not know the exact time to do. Can anybody help me with this, I've already looked for this type of stuff but there is nothing to answer my question.
Server Script:
replicatedStorage = game:GetService("ReplicatedStorage")
replicatedStorage.RE.Dance3.dance3:FireClient(plr,true)
LocalScript:
function dance3(operation)
if operation == true then
local name = game.Players.LocalPlayer.Name
local Humanoid = game.Workspace:WaitForChild(name).Humanoid
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=182436935"
game.ReplicatedStorage.RE.Dance3.Value.Value = true
local animTrack = Humanoid:LoadAnimation(animation)
while game.ReplicatedStorage.RE.Dance3.Value.Value == true do
wait()
animTrack:Play()
end
elseif operation == false then
game.ReplicatedStorage.RE.Dance3.Value.Value = false
end
end
game.ReplicatedStorage.RE.Dance3.dance3.OnClientEvent:Connect(dance3)

2 comments
put: animTrack.Looped = true
dont use instance.new and animations i find that to not work sometimes