game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(message)
processCommand(player, message)
end)
function processCommand(speaker, message)
if message == script.MessageComand.Value then
local bro = game.Workspace:FindFirstChild(speaker.Name)
local newanim = script.AnimationOne:Clone()
newanim.Parent = bro
local hum = newanim.Parent.Humanoid
local anim = hum:LoadAnimation(bro.AnimationOne)
anim:Play()
newanim:Destroy()
wait(amount of time you want to wait)
anim:Stop()
end
end
This can be an issue with your animation’s priority. (It’s too high).
But the issue is that you didn’t call the :Stop
function of AnimationTrack
.
animationTrack:Stop();
You can yield (or pause) for however long the animation is, and then stop the animation.
No as this runs on a function and an event there is nothing to wait for…
If he Dosent wait when he fixes it, it will automatically stop I think.
Code with bad practices aside, this probably has to do with your animation. Did you make it loop? You can either turn looping off or turn the property off in code:
-- Append this below anim:Play()
anim.Looped = false
Otherwise, aside from that, the animation priority is most likely too high. You have to stop this yourself when a user’s state changes - that’s not accounted for in your code.
Not sure why you are suggesting waits. Waits don’t have anything to do with whether or not an animation stops. There’s no need to even have a wait statement present in this code.
@NYDynamics
No it’s not and you shouldn’t be using wait with this in mind. Wait sleeps the thread from executing for a specified amount of time. If n is not specified, it will wait approximately 1/30th of a second.
Or you can not reinvent the wheel and use game.Loaded:Wait()
instead. The Loaded signal and IsLoaded method determine when the server finishes replicating instances to the client.
The whole point on wait/Loaded is irrelevant for the purposes of this thread in the first place. It’s about stopping an animation.
What exactly do you mean by “Roblox doesn’t load in time”? Wait doesn’t prevent anything. If you need to use a wait unnecessarily in your code, you are writing your code wrong (and the point is wrong as well). There’s no such scenario.
Again, this is irrelevant for the purposes of the OP. Please DM me if you wish to continue further discussion.
I’ve been trying all of the stuff you’ve all been saying, but either the emote stays looped even while walking or cancels out while walking but cancels out while idea which is not what I want.
I want my emote to loop while being idle but cancel out when walking or jumping. Please give me other ideas to fix it ;-;
Your priority is too high then, if it continues even whilst walking or jumping.
Core is the lowest priority,
Idle is second to lowest,
Movement is second to highest,
Action is the highesty priority.
Your priority is either movement or action. Try using Idle
.
You are able to assign the AnimationPriority
programmatically, like so:
anim.Priority = Enum.AnimationPriority.Idle;
You can also do this from your animation settings with the animation editor plugin.
I tried using Idle, it acts the same as movement and action, when I use core, I can use the emote when I just spawn but when I move I can’t use the emote, and the scripts to make it idle or loop or not don’t work…
You are contradicting yourself.
What exactly are you trying to do?
I am trying to make an emote that doesn’t end (Example: the default dances that roblox already has)
but ends when you move or jump
If nothing is working for you right now, how about this:
How about you detect when a player is jumping, you stop the animation.
humanoid.Jumping:Connect(function()
anim:Stop();
end);
And when they are walking, stop it as well
humanoid.Running:Connect(function(speed)
if (speed < 0.1) then
return; --// too slow to even be considered running
end
anim:Stop();
end);
Ok i’ll try that when I finish this round of Horrific Housing
Hey incapaxx, where do I put those 2 bits in the script?
Everywhere I put them it has an error…
Can you specify the error you are getting?
I have the script like this:
game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(message)
processCommand(player, message)
end)
end)
function processCommand(speaker, message)
if message == script.MessageComand.Value then
local bro = game.Workspace:FindFirstChild(speaker.Name)
local newanim = script.AnimationOne:Clone()
newanim.Parent = bro
local hum = newanim.Parent.Humanoid
local anim = hum:LoadAnimation(bro.AnimationOne)
anim:Play()
end
end
humanoid.Jumping:Connect(function()
anim:Stop();
end);
if (speed < 0.1) then
return;
end
anim:Stop();
end);
But that final end says expected eof instead of end
I got rid of the end issue but now the script says
attempt to index global ‘humanoid’ (a nil value)
and it says that to humanoid, anim, speed, and the other anim in the bit of coding you gave me, why are those things “a nil value”
Can you post your most recent code? Also try to format it correctly as code, that will make it much easier to read.
Check out animation priority. This might be able to solve your issue by allowing the walking animation to override yours. AnimationTrack | Documentation - Roblox Creator Hub
Lastly (if priority doesn’t work), to stop an animation while walking, you’d want to use a .Changed event on the humanoid and check for walkspeed.
That was meant to be more of pseudo-code, this code works assuming you’ve defined humanoid
, and such. It’s more for an idea of how to fix your problem, not copy paste friendly code.
My current script is like this:
game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(message)
processCommand(player, message)
end)
end)
function processCommand(speaker, message)
end
if message == script.MessageComand.Value then
local bro = game.Workspace:FindFirstChild(speaker.Name)
local newanim = script.AnimationOne:Clone()
newanim.Parent = bro
local hum = newanim.Parent.Humanoid
local anim = hum:LoadAnimation(bro.AnimationOne)
anim:Play()
end
local hum = Workspace.Player.FindFirstChild("humanoid")
if hum.Jumping:Connect(function()anim:Stop();
end)
then if (humanoid.speed < 0.1) then anim:Stop()
end
end