Player.Chatted Not Returning Anything

Hello DevFourm, I have an annoying problem with the Player.Chatted event. I am making a system where when a player types for example “/teleport” in the chat it moves their character to a position of a part. I made a script with:

if msg == "/teleport" then
   plr.Character:MoveTo(game.Workspace.(the part).Position)

but that didn’t work. So I tried the print method and printing what the player said, but that didn’t work either. I don’t know how to explain it so I’ll give you the script:

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		print(msg)
	end)
end)

(I try saying something in chat but the script returns nothing despite me printing the chatted event)
(This runs in a server script located inside the part I want the player to teleport to)

Thanks :slight_smile:

3 Likes
  1. Is the script enabled?

  2. Is it a server script or local script?

Yes, the script is enabled, and it’s in a server script.

Wait, put this in serverscriptservice.

Server scripts wont run under part

Try adding a task.wait() statement between the joining and chatting events. We might need to see some more of the script.

Server scripts do run under parts.

  1. make sure you are using legacy chat,

  2. make sure you are doing this on a client script.

this should fix it…

it’s generally a bad practice to put scripts under parts, the issue could be that your player added event connects late. scripts in serverscriptservice run before anyone joins the game, but i’m not sure if that is the case with scripts under parts.

1 Like

these do not fix anything. aaaaaaaaaa

Works now! Thanks for your help :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.