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.
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.