I have a loop where I am going through all the players and making them emote one at a time… I fire an event to the client which plays the emote.
I am thinking about maybe having a completed event on the client that will fire to the server letting the server know the player is done and then having a repeat wait until that debounce gets set… then it would go to the next player and so on.
[UPDATE: scratch this because it’s game breaking if someone decided to exploit] → so i think it will have to be a method that is server based.
does anyone have any suggestions for this?
Here’s some sudo:
for every player in the game
activate emote (fire client)
repeat
wait
until emote completed
-- loop continues to the next player
note: maybe there is a humanoid event i can get on the server that will let me know when the animation is finished (currently researching)
You could do it on the server (would be easier) and use a .Stopped event on the animation. But if you want to start the animation on the client, maybe using a queue with a remote event. So basically you create a queue and push all the players into it, and every time the event is fired to the server (player finishes emote) it checks the queue head and if the player is the same whos next in the queue it pops the head and then sends the dance emote to the next player until the queue size is 0 (no more players to emote)
Also make sure to add a timeout that automatically makes the next players in queue start dancing just incase the current emoting player leaves the game or something and cant send the completed signal to the server
so for this i’d have the player be moved back to another position once finished emoting. i didn’t put that bit in description. i thought animations were meant to be played on client though… would it work just fine if played on server?
yeah ig but that’s cringe and more work than just adding a task.delay(animationLength) function and then task.cancel() on it once the .Completed thing runs
may be more work but better code quality overall right? task.delay(animation length) doesn’t seem like the best practice to me. seems kind of jank. i’d prefer to get rid of any possible race conditions so more work is fine if it does that. going with the conditions i cna also customize the user experience more if a player does end up leaving mid game. vs task.delay which may create awkwardness
Sure, but you’d also have to check if the player dies too btw and a couple other conditions that could prevent the animation from completing so timeout is easier imo
yeah i’m not too worried about what’s easiest because this is production code. i’m more concerned with customizing the user experience and making it as smooth/ high quality as possible
for every player in game
-move to dance position
-play dance emote
-set player dancing to player name
–if player leaves game then
—set player dancing to nil (which would continue to next player automatically instead of waiting the emote time, which would be jank. could also add customized ui saying a player left and can turn off whatever ui was supposed to be on during the player dancing)
i wonder if you could use GetPlayingAnimationTracks(): on server and connect the .completed event through that value then still be able to play the animation on client. just a thought though while reading api