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

How do I make this kill cmd script only for one player?

I want to make it so only a specific player can do this:

function chat(msg, sender)

	local delimiter_point=msg:find("/", 1, true) --Find the delimiter in the string

	if delimiter_point then --Make sure it's actually there

		local command = msg:sub(1, delimiter_point-1)

		local arg = msg:sub(delimiter_point+1)

		--We have the command and argument. It's now time to start with the commands :D

		

		if command == "message" then

			local x = Instance.new("Message", Workspace) --Create a message

			x.Text = arg --Set its text to the text after the delimiter

			game.Debris:AddItem(x, 5) --Remove the message after five seconds.

		elseif command == "kill" then

			if game.Players:findFirstChild(arg) then --See if player is in game

				local x = game.Players:findFirstChild(arg) -- Set a variable for the player found

				if x.Character then --Make sure the player has a character so we can kill it

					x.Character:BreakJoints() --If character found, then kill character.

				end

			end

		end

	end

end



game.Players.PlayerAdded:connect(function(plr)

	repeat wait() until plr.Character

	plr.Chatted:connect(function(msg)

		chat(msg, plr)

	end)

end)

2 comments

0

if sender ~= 'username' then return end

0

Try if plr.UserId == "Your UserId" then chat(msg, plr) end

1 answer

✓ Accepted answer
game.Players.PlayerAdded:Connect(function(plr) -- THIS EVENT RUNS WHEN A PLAYER IS ADDED TO THE GAME
	if plr.UserId == 000000000 then --CHECKS THE USER ID OF THE PLAYER [REPLACE 000000000 WITH THE USER'S ID]
	--THE SCRIPT YOU PUT HERE WILL RUN ONLY IF THE PLAYER'S USER ID IS THE SET USER ID
	end
end)

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