Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Kicking a player when touching a brick, except if they're an admin?

Asked by 7 years ago
Edited 7 years ago
local player = game:GetService("Players"):WaitForChild("LocalPlayer")
local admin = {"Player",
               "Player2",

}

script.Parent.Touched:connect(function(hit)
    if hit.Name == "Humanoid" then
    for i,v in pairs(admin) do
        if player.Name == v then
            return admin
        else 
            if player.Name ~= v then
                player:Kick("You are not an admin")
            end
        end
    end
end
end)

So I wanted to make a script where if a player touches a brick and they're not in the admin table, they get kicked. If a player touches the same brick and they're in the admin table, then they don't get kicked and nothing happens to them. I wrote this code in a local script, and put it in the brick.

No errors showed in the output, and when I touched the brick, nothing happened.

0
Please use code block. RedCombee 585 — 7y
0
Check the wiki on how to make a kill brick and how to make an admin door, then combine the two, basically. GoldenPhysics 474 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

1st I would not kick a player using a localscript

2nd hit.Name would never be Humanoid except it the part which touched it is named Humanoid.

3rd I would not kick by player name as users can change their name

I would use UserId to check the player.

Some hits

You can get the player from the model by using this method GetPlayerFromCharacter

Then check the players UserId against a pre made table, using a table with keys will mean that you will not need to search for the players id.

Hope this helps.

0
Good suggestions. funzrey 58 — 7y
Ad

Answer this question