Custom /e commands

What I’m trying to find out is how to make custom /e commands play a specific animation and delay walk speed and/or make it impossible to move. I also don’t want the animation to end if I move. So what I’m trying to do is making it if a player say /e hands their hands would go up (like hands up, like you do when someone points a gun at you). I want the wall speed to be slowed down and the animation to still continue even when you walk. I also don’t want the animation to end unless you say /e hands or another /e command after using the /e hands command.

I’m not a scripter so examples and instructions would be appreciated.

So, how do I achieve this?

(I looked quickly over some videos regarding the topic but it was either outdated or not exactly what I wanted)

7 Likes

If you wanted it to end as soon as you start walking, that would be as easy as putting id’s in Roblox’s Animate script.

In your case, you’ll have to script these yourself;
Something like this should work:

local player = game:GetService('Players').LocalPlayer
local emotes = {
 hands_up = "rbxassetid://0000"
};

for i,v in pairs(emotes) do
 local anim = Instance.new('Animation')
 anim.AnimationId = v
 emotes[i] = anim
end

player.Chatted:connect(function(message)
 if message:sub(1,3) == "/e " then
  local emote = message:sub(4)
  emote = emotes[emote]
  if emote then
   if emote.IsPlaying then emote:Stop() else emote:Play() end
  end
 end
end
24 Likes

It may be a bit stupid question… But where would I place the script? Local or not? I’m still learning and I’m honestly not sure. :sweat_smile:

2 Likes

LocalScript, hence game:GetService('Players').LocalPlayer

2 Likes

There’s a script called “Animate” inside of Roblox’s Character, you could take it, edit it and place it in “StarterPlayerScripts”, or if you’d like, in a local script.

1 Like

OP wants the animation to play until you stop it manually.
Roblox’s Animate emotes stop once you start walking.

3 Likes

Then the second option works, local script.

When I use the script you provided the game’s chat turns invisible 5/10 times. But even when it doesn’t the animation doesn’t play after saying /e hands_up.
image
How do I fix this?

1 Like

This is a bug on Roblox’s end, not related to the script you used. The script should work if your press play on the games page.

I think you misunderstood me. I’ve tested it, and it doesn’t work even when the chat acts normally.

1 Like

I wasn’t referring to your commands not working, I was talking about the inconsistency of the chat window, sorry if I confused you.

1 Like

You forgot to load the animation.

Yes, my bad.
I wrote that code inside the browser, and it was only meant to be example.
Thanks for letting me know.

So how would I fix this? I’ve attempted myself but with no success.

1 Like

You should just preload the animation in the loop at the beginning of the script.
I’d show you an example, but unfortunately, Im on mobile right now.

How would I do that to be exact? I can wait for an example if you want.

Use the ContentProvider service.

Please have a look around the DevForum or Developer Hub for answers to some of the questions you posed. Searching “preload” on either website would yield you the answer you need.

1 Like

I’ve already attempted to look it up before I asked how to do it, but I didn’t understand much. But I appreciate that you are trying to help me. :slightly_smiling_face:

1 Like

It’s quite explicitly documented how to use this. All services are retrieved using GetService, which ContentProvider is. PreloadAsync is a function of ContentProvider which allows preloading. It accepts a table of Instances.

Preloading is irrelevant to this scenario though. Preloading at the beginning of a loop is unnecessary since an asset only needs to be downloaded once and the act of loading was not in reference to preloading, it was readying the Humanoid to use an Animation instance.

1 Like

Its not related to preloading assets in this case, it’s related to loading anims to humanoid.

In loop:
Emotes[i] = Player.Character.Humanoid:LoadAnimation(anim)

I’m sadly still on mobile and can’t format the code right, but I hope you understand from this.