Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Confused on how to do a /kick chatted event?

So Im trying to make a command where if a developer chats "/kick (players name)" it kicks them, but i'm super confused on how to reference the player. Any help?

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg == "/kick"..game.Players:GetPlayers().Name then
			game.Players:GetPlayers().Name:Kick()
		end
	end)
end)

3 comments

0

How about a while true do loop and for loop that consistently checks if there is a player in the game who is a developer? If they are then you can execute the code however you want.

0

That's not the problem, the problem is I can't reference the player from a message.

0

Oooh.

1 answer

I figured it out lol.

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if string.sub(msg,1,5) == "/kick" and plr:FindFirstChild("DEVELOPER") ~= nil then
			local player = game.Players:FindFirstChild(string.sub(msg,7))
			 if player then
				player:Kick()
			end
		end
	end)
end)

5 comments

0

there's like only 2 differences from pawels answer...

0

Not only that, but you also didn't mention that for this to work there would have to be a tag called "DEVELOPER" in the player.

0

@MythicalShade Ik, because that was uneeded at the time. You did exactly want I wanted.

0

Why was this downvoted?

0

Oh my bad SBlankthorn I didn't realize you were the person asking the question so I thought that the person asking the question wouldn't understand the "Developer" part lmao my bad.

This discussion is preserved as it was. New answers, comments, and votes are closed.