So I was making my own chat system that if the player typed /e dance the player would play an animation. I also made some events to check if the player was moving. I did try to search but it still doesn't work.
This is the script:
game.ReplicatedStorage.ChatMessage.OnServerEvent:Connect(function(p, msg)
if msg ~= "/e dance" then
-- code
else
local char = p.Character
local hum = char.Humanoid
local anim = char.Animations.Dance
local track = hum:LoadAnimation(anim)
if hum:GetState() == Enum.HumanoidStateType.None then
track:Play()
end
hum.Jumping:Connect(function(jump)
if jump then
track:Stop()
end
end)
hum.Died:Connect(function()
track:Stop()
end)
hum.FreeFalling:Connect(function(fall)
if fall then
track:Stop()
end
end)
hum.StateChanged:Connect(function(state)
if state == Enum.HumanoidStateType.Landed then
track:Stop()
end
end)
hum.StateChanged:Connect(function(state)
if state == Enum.HumanoidStateType.Freefall then
track:Stop()
end
end)
hum.StateChanged:Connect(function(old, new)
if old == Enum.HumanoidStateType.Climbing then
track:Stop()
elseif new == Enum.HumanoidStateType.Climbing then
track:Stop()
end
end)
hum.Running:Connect(function(spd)
if spd > 0.1 then
track:Stop()
end
end)
hum.Seated:Connect(function(sit)
if sit then
track:Stop()
end
end)
end
end)
