I have this script that kicks a player but it doesn't kick?
local gamepass = 0 -- Gamepass ID here game.Players.PlayerAdded:connect(function(plr) if game:GetService('GamePassService'):PlayerHasPass(plr,gamepass) then elseif plr.UserId == 8021038 then elseif plr.UserId == 161916404 then else plr:Kick('No access.') end end)
What you're trying to do is not allowed, as you're trying to kick a player the moment they join. The reason this occurs is because you're trying to set the parent of something to something, while roblox itself is parenting the player to the Players service.
Simply typing in a wait()
inside of the function should make it work.
(I've also compacted your if statment)
local gamepass = 0 -- Gamepass ID here game.Players.PlayerAdded:connect(function(plr) wait() if not game:GetService('GamePassService'):PlayerHasPass(plr,gamepass) and plr.UserId ~= 8021038 and plr.UserId ~= 161916404 then plr:Kick('No access.') end end)