Chat Emote Creation Help Needed

Hello! I’m trying to make a roblox emote, I’m trying to make /e swat to spawn a door in-front of the player executing the command and and it exploding open and falling apart with an audio playing inside the door. How would I do this?
image

Well, you can use the ROBLOX chat API’s. Or, you can take, what I believe to be, the easier but not as well built, .Chatted event. I am not good with the chat API’s and would probably use the second one.

game:GetService("Players").PlayerAdded:Connect(function(plr)
        plr.Chatted:Connect(function(msg)
                if string.lower(msg) == "/e swat" then
                      --Execute code here
               end
               return
        end)
end)

That is the .Chatted way. But if you want to use the other method I recommend your read this article. But, with that method you have to update it and remake it when the chat APIs get updated. Because, you make your own custom chat and overwrite ROBLOX’s auto-loaded one. I’m sure someone more experienced than me can think of something else but, those are the methods I know of.

I have that up, but I’m unsure how to make a door pop up 2 studs in front of the player executing it…

Im need to go so I may or may not respond tonight or tomorrow.

What you might be able to do is have the door in Server Storage, and when the player chats you could change the model’s primary CFrame to be right in front of it.

If you want you want to have it in front of the player you would need a way to get the parts rotation.

How would I do this as I have never done anything with C Frame or getting a player’s rotation. What would be a good starting point for a script?

The current script I have is:

> function onChatted(msg, speaker)
> 
> source = string.lower(speaker.Name)
> 
> msg = string.lower(msg)
> 
> local SWAT1 = game.Workspace.SWATE
> 
> local SWAT2 = game.ServerStorage.SWATE
> 
> local plr = game:GetService("Players")
> 
> if msg == "/e swat" then
> 
> print("Starting Command!")
> 
> SWAT2.Parent = workspace
> 
> SWAT1:SetPrimaryPartCFrame(plr.Character.HumanoidRootPart.CFrame + plr.Character.HumanoidRootPart.CFrame.LookVector * 12)
> 
> wait(0.1)
> 
> print("Playing Sound!")
> 
> SWAT1.FBI.Head.Sound.Playing = true
> 
> end
> 
> end
> 
> function onPlayerEntered(newPlayer)
> 
> newPlayer.Chatted:connect(function(msg) onChatted(msg, newPlayer) end)
> 
> end
> 
> game.Players.ChildAdded:connect(onPlayerEntered)

I suggest you start by looking into these two posts.

https://devforum.roblox.com/t/how-to-think-about-cframes/11743/47

Cool! Also on game.Players.ChildAdded:connect(onPlayerEntered) you should use game:GetService("Players").PlayerAdded:Connect(onPlayerEntered") you shoud use :Conect instead of :connect because :connect is deprecated. And you should use :GetService("Players") instead of .Players because Players can be renamed and using :GetService ignores the renamed Players and will still work without erroring. Otherwise if it is renamed and you’re using .Players it will error because nothing named Players exists.

Okay, that helps me a bit. Now I just need to firgue out the C Frame vector’s I think I figured it out though…

I gtg so tomorrow I will continue this post based on what happens with this script.

Nope, still not working… Could I have some help figuring it out… The C Frame vector’s are confusing…

You should consider using a Roblox animation, you can learn more about them via the wiki. You have the right idea when it comes to allowing people to run a “custom” animation such as /e swat but you can take an easier route by definitely using Roblox animations.

Thanks for the help! It worked out!

2 Likes

I’m glad you solved it! :smiley:

Can you put here how you solved it with a ROBLOX animation?

I told him how to solve it, he used my method and it worked for him. That is why he marked my answer as the solution. You’d have to ask him how he implemented the Roblox animation as I do not know.

1 Like

Oof, I replied to the wrong person. Sorry.