I'm new to scripting & trying to make a gamepass which plays animations on specific chatted messages, but I don't know where I've gone wrong. Nothing showing in output or dev console. Anyone able to help?
service = game:GetService("GamePassService") gamepass = 000000 --edit this later player = game.Players humanoid = player:WaitForChild("Humanoid") animation = game.Lighting("Animation") play = humanoid:LoadAnimation(animation) wait() game:GetService("Players").PlayerAdded:Connect(function(Player) Player.Chatted:connect(function(Message) if Message == "/e test" and service:PlayerHasPass(player, gamepass) then play:Play() end end) end)
`
The problem here is: You're not referencing the player. In line three, the variable is referencing game.Players, which is a service. After fixing that, you'd have to use Player.Character in line 4 to reference the humanoid. The final problem is you didn't use WaitForChild on the animation variable. Here's a fixed version of your code:
service = game:GetService("GamePassService") gamepass = 000000 --edit this later player = game:GetService("Players").LocalPlayer humanoid = player.Character:WaitForChild("Humanoid") animation = game.Lighting:WaitForChild("Animation") play = humanoid:LoadAnimation(animation) wait() --This could possibly prevent the first player that entered from running the below code. game:GetService("Players").PlayerAdded:Connect(function(Player) Player.Chatted:connect(function(Message) if Message == "/e test" and service:PlayerHasPass(player, gamepass) then play:Play() end end) end)