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

How should i go around killing someone on join if they are on a blacklist?

I have already attempted they good old

player.Humanoid.MaxHealth = 1
player.Humanoid.Health = 0

But of course, that wont work due to humanoid not being part of the Player class. I have attempted a search, but didn't come back with any luck, any help at all would be lovely :)

1 comment

0

You can do player:Kick().

2 answers

✓ Accepted answer

All players have a "character", which is the model that you control when playing the game. Example code could be:

player.CharacterAdded:Connect(function(Char)
	local Humanoid = Character:WaitForChild("Humanoid", 5)
	if Humanoid then
		Humanoid.Health = 0
	end
end)

Obviously make sure to see if they're on the blacklist before killing them, I would recommend creating a table full of UserIDs and checking if the player that joined the game has their UserID in the table.

2 comments

0

I get where you are going, but spawn protection (force field), protects the user from not dying.

0

If you want to bypass the Forcefield, either just set the Humanoid Health manually instead of using :TakeDamage(), or use Char:BreakJoints()

If you were to attempt this, you'd obviously have to call characteradded. Heres an example.

local Players = game:GetService("Players")

local Blacklist = {"noob1", "noob2"}

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:WaitForChild("Humanoid")
		for i = 1, #Blacklist do
			if Blacklist[i] == Player.Name then
				Humanoid:TakeDamage(Humanoid.MaxHealth)
			end
		end
	end)
end)

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