wait(1)
local player = game:GetService('Players').LocalPlayer
local Player = game.Players.LocalPlayer
local vCharacter = Player.Character
local myHumanoid = vCharacter:WaitForChild("Humanoid")
local playing = false
cooldown = 0
local emotes = {
HandsUp = {myHumanoid:LoadAnimation(script.HandsUp),"Hands",8},
Detained = {myHumanoid:LoadAnimation(script.Detained),"Detain",8}
}
function ResetAll()
for i,v in pairs(emotes)do
v[1]:Stop()
myHumanoid.WalkSpeed = 16
end
end
player.Chatted:connect(function(message)
if cooldown > 0 then return end
for i,v in pairs(emotes) do
if message:sub(1,3) == "/e " then
if message:sub(4) == v[2] then
if playing == false then
emote:Play()
myHumanoid.WalkSpeed = v[3]
playing = true
script:WaitForChild("enabled").Value = playing
script.AnimateEvent:Fire("Animate", true)
elseif playing == true then
ResetAll()
playing = false
script:WaitForChild("enabled").Value = playing
script.AnimateEvent:Fire("Animate", false)
end
cooldown = 3
end
end
end
But that doesn’t work either. What have I done wrong? How do I fix it?
This is how it looks like.
Sorry for not replying earlier, heres the fix.
In the loop settings the emotes table, it wasn’t loading animation on the humanoid, but it guesses that the animation is loaded when typing emote.
It would look something like this in the end:
local player = game:GetService('Players').LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local humanoid = character:WaitForChild('Humanoid')
local emotes = {
hands_up = "rbxassetid://0000"
};
for i,v in pairs(emotes) do
local anim = Instance.new('Animation')
anim.AnimationId = v
emotes[i] = humanoid:LoadAnimation(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)
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)
because :Connect(function(message) need a end) and not a end