I’m trying to make custom chat animations, via the chat ofc. For example if a player does /e sit it does a custom sit animation that allows them to move, still be doing the animation but to stop doing the animation they have to do another command called “/e unsit”. I tried looking for other threads on people trying to find or a way to do this but the ones I found aren’t like the one’s I’m looking for. I attempted at trying to do it on my own but it exceeded my scripting capabilities as I am still a beginner.
I was wondering if anyone has made this type of script before, or for someone to lead me to the right path on making it.
Can you post your attempt so we can give you feedback on how to improve it?
Anyway, you can do this via the Player.Chatted event to see when a player has chated. Then, you can check the message to see if it matches the commands. If the message matches, play/stop the animation.
local Anim = Instance.new("Animation")
Anim.AnimationId = ""
game.Players.PlayerAdded:Connect(function(player)
local track
player.Chatted:Connect(function(msg)
if msg:lower() == "/e sit" then
track = player.Character.Humanoid:LoadAnimation(Anim)
track.Looped = true
track:Play()
elseif msg:lower() == "/e unsit" then
if track then
track:Stop()
end
end
end)
end)
Also, yes I know this isn’t very neat but I’m not on pc atm.
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if msg == "/e sit" then
print("ABLE TO SIT")
end
end)
end)
Only downside to this is a message in the chat pops up saying “you cant use that emote” even though the script works. You can add an elseif for the unsit command as well.
just a quick tip, but you should probably use msg:lower() or string.lower() to change all letters in their message to lowercase
also @A_thruZAlt, i believe that it wouldn’t make sense because the .Chatted event still occurs when you spam something and the message doesn’t come up in the chat
no, i meant as in spamming and then the message doesn’t appear because you kept typing a lot of messages in a short period of time. however, the .Chatted still fires even when the system tells you that you have x amount of seconds remaining before you can message
I would recommend caching the loaded animation and loading it on the client instead. str:func() is slower than string.func(str). Also if you wanna add a lot of custom commands without too much spaghetti here is what you could do. @ISieSky
local Player = game.Players.LocalPlayer
local Callbacks = {
Sit = function()
end
}
Player.Chatted:Connect(function(Message)
local Function = string.match("/e") and string.gsub(Message, 3, #Message)
if Function then
Callbacks[Function]()
end
end)
It works now but it appears the characters animation makes them float above the surface and the normal roblox animation overrides the actual sitting animation.