So I have tried to create a block that kicks players, but not the people in the written string:~~~~~~~~~~~~~~~~~
("Fla_res,gloveshun") ~ And I have written a code that kicks people that hit the block. It has been succesfull, due to the output BUT I am trying to destroy the table so that the people in the string do not get kicked. If i've written something wrong please tell me since i am a new scripter. here is the code: ~~~~~~~~~~~~~~~~~
script.Parent.Touched:connect(function(onTouched) game.Players:FindFirstChild("Humanoid"):kick("You have been kicked for not listening to what I have said.") if localPlayer ("Fla_res,gloveshun")
after local player , I got stuck and confused
So im guessing you're trying to make it so that you can check whos in the table, and if they're not in the table, you want to kick them. Thats pretty straightforward. Here's how I would do it:
--Psudar --Sep 1 2019 --Server Script (Parented to part) --//Services local Players = game:GetService("Players") --//Instances local Part = script.Parent --our table of players allowed local WhiteList = {"Psudar", "Rorarius", "ii_Pekk"} --//Functions --this finds the player in a table using name local function AllowedPlayer(tbl, playername) for i, v in pairs (tbl) do if v == playername then return true end end end local function onTouched(hit) if hit.Parent:FindFirstChild("Humanoid") then --we can get the player from their character like this: local PlayerWhoTouched = Players:GetPlayerFromCharacter(hit.Parent) --we use our function to check if they're whitelisted if not AllowedPlayer(WhiteList, PlayerWhoTouched.Name) then --if they arent, kick them PlayerWhoTouched:Kick("You're not allowed") end end end --//Connections --connect the touched function when part is touched Part.Touched:Connect(onTouched))
Basically all we do here is run a function when the part is touched. We have an if-statement that determines if the player is allowed. If they're not, we simply kick them. The function that determines that literally just looks inside the table for the player's name, if its not, we kick them.Simple as that! :D
bro, what is this? can i help ya? My whitelist script:
local WhiteList = {"gloveshun", "Fla_res"; "Player...?"} game.Players.PlayerAdded:Connect(function(player) for i, v in pairs(WhiteList) do if not player.Name == WhiteList[v] then player:Kick("You are no allowed here!") else print(player.Name.." Passed!") end end end)