What do you want to achieve? Keep it simple and clear!
I would like on chatting /e pvz, you would start dancing and a song would play.
I don’t think there was any errors, but it did not work at all.
LOCAL SCRIPT
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local run = Instance.new("Animation")
run.AnimationId = "rbxassetid://5496426679"
local runtrack = humanoid:LoadAnimation(run)
local Players = game:GetService("Players")
local dance = "/e pvz"
local function dance(player)
local function onPlayerChatted(player, message)
if message:sub(1, dance:len()):lower() == dance() then
runtrack:Play()
game.Workspace.Dance:Play()
I did add that exact line to the script
Anyways, I did remove the function though, thanks for telling me, however it still doesnt work
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local run = Instance.new("Animation")
run.AnimationId = "rbxassetid://5496426679"
local runtrack = humanoid:LoadAnimation(run)
local Players = game:GetService("Players")
local dance = "/e pvz"
local function onPlayerChatted(player, message)
if message:sub(1, dance:len()):lower() == dance() then
runtrack:Play()
game.Workspace.Dance:Play()
end
end
You never call the function, here’s the fixed script:
local plr = game:GetService('Players').LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait() -- :wait() is deprecated
local humanoid = char:WaitForChild("Humanoid")
local run = Instance.new("Animation")
run.AnimationId = "rbxassetid://5496426679"
local runtrack = humanoid:LoadAnimation(run)
local dance = "/e pvz"
plr.Chatted:Connect(function(Message)
if Message:lower() == dance then
runtrack:Play()
end
end)