I feel like you need to do a bit more research into this topic and do your own debugging. It doesn’t seem like either of those two things have been done, which is the cause for some of these mistakes. Please do keep the Scripting Support category guidelines in mind.
When creating custom chat commands, you don’t need the second argument - that’s recipient, it describes a player who a message is being sent to. This is for whisper chats. The only parameter you need is the first one, which is the message the player wrote.
Another thing you’re going to want to do is perform the group check before the chat command, or better yet perform the group check before registering chat functions. Rank checks in groups are internally web calls and you don’t do your server any good by constantly making calls per chat.
'nother tidbit of code: you can directly connect your function to Chatted instead of hooking a function to call a function. It’s redundant and should not be included.
This is about what you’re able to do. Don’t directly copy and paste my code into a script because there are things missing and it’s only crude code, not full code: you need to fill that out for yourself. That’s not something I’m going to freely hand.
local function onPlayerAdded(player)
if player:GetRankInGroup(0) >= 0 then
-- We keep it here for ease of access
player.Chatted:Connect(function (message)
message = message:lower()
-- Consider a dictionary of location names and positions here
if message == "!lobby" and player.Character then
player.Character.HumanoidRootPart.CFrame = TeleportLocationPosition
end
end)
end
end
-- Use PlayerAdded, not ChildAdded
Players.PlayerAdded:Connect(onPlayerAdded)
for _, player in ipairs(Players:GetPlayers()) do
onPlayerAdded(player)
end
Please be sure to try things out yourself and do some debugging. You can also read up on the API via the Developer Hub as it’d explain certain things to you. If you had read the Chatted page, you’d realise that the second parameter is a string, not a player.