Ad
Log in to vote
0

Kick script doesn't kick the player?

Asked by 5 years ago

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)
0
The only error is this 'Something unexpectedly tried to set the parent of Player1 to NULL while trying to set the parent of Player1. Current parent is Players.' theevanegps2 15 — 5y
0
maybe add a wait at the start Volodymyr2004 293 — 5y

1 answer

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
5 years ago
Edited 5 years ago

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)
0
Why not have it when the player's character loads? What I mean is the CharacterAdded event. (CharacterAdded:Wait()) TheeDeathCaster 2368 — 5y
0
TheeDeathCaster has a point. Unless theevanegps2 has CharacterAutoLoads disabled. Programical 653 — 5y
0
There's no need for that. RubenKan 3615 — 5y
Ad

Answer this question