It is kind of difficult to write it in a sentence for people to understand. Recently I have been trying to make a script in which anyone who isn't in a designed whitelist will have a NPC target them down, which will cause them to get kicked on touch. It worked, but when they rejoin or another person joins. The NPC does not spawn in. Sort of need some help in regards to this.
Here is the script I had trouble on
--Whitelist script by fridayboycool : Modified by XenilMatrix [HUGE CREDITS TO OWNER] local whitelisted = { ["XenilMatrix"] = true; [""] = true; ["Player1"] = true; } local player = script.Parent.Parent local teams = game.Teams -------------------------------------------------------------------------------------------------------------------- while true do wait(0.01) if whitelisted[player.Name] then else -- 2020/3/31 Got it working but failure to repeat again when another invalid person joins the game, but they are not listed. while true do wait(0.001) if #teams.Players:GetPlayers() > 0 then local Object = game.ReplicatedStorage["NPC"]:Clone() Object.Parent = game.Workspace Object.Position = Vector3.new() Object:MoveTo(Vector3.new(0,0,0)) wait(0.001) end end end end
--Whitelist script by fridayboycool : Modified by XenilMatrix [HUGE CREDITS TO OWNER] local whitelisted = { ["XenilMatrix"] = true; [""] = true; ["Player1"] = true; } local player = script.Parent.Parent local teams = game.Teams game.Players.PlayerAdded:connect(function(plyr) repeat wait() until plyr.Character if not whitelisted[plyr.Name] then local object = game.ReplicatedStorage["NPC"]:Clone() object.Parent= game.Workspace object.Position = Vector3.new() while wait(.03) do if not whitelisted[plyr.Name] ~= nil then object:MoveTo(Vector3.new(0, 0, 0)) else break end end end end)
I'm confused as to why you don't do this on the server. I don't understand any of your bot stuff so I'll just have you do that manually
Disclaimer: Put this in a script on the server
local whitelisted = { ["XenilMatrix"] = true; [""] = true; ["Player1"] = true; } game.Players.PlayerAdded:Connect(function(player) local character = player.Character or player.CharacterAdded:Wait() local touched = false if not whitelisted[player.Name] then while true do wait() ##Bot following player here end end end)
I should probably break the loop as soon as the player gets kicked but I can't be bothered to test if it would work.
Make sure to tell me if this helps