Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Kick script doesn't kick the player?

Asked by 8 years ago

I have this script that kicks a player but it doesn't kick?

01local gamepass = 0 -- Gamepass ID here
02game.Players.PlayerAdded:connect(function(plr)
03    if game:GetService('GamePassService'):PlayerHasPass(plr,gamepass) then
04 
05    elseif plr.UserId == 8021038 then
06 
07    elseif plr.UserId == 161916404 then
08 
09    else
10    plr:Kick('No access.')
11    end
12end)
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 — 8y
0
maybe add a wait at the start Volodymyr2004 293 — 8y

1 answer

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
8 years ago
Edited 8 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)

1local gamepass = 0 -- Gamepass ID here
2game.Players.PlayerAdded:connect(function(plr)
3wait()
4if not game:GetService('GamePassService'):PlayerHasPass(plr,gamepass) and plr.UserId ~= 8021038 and plr.UserId ~= 161916404 then
5        plr:Kick('No access.')
6    end
7end)
0
Why not have it when the player's character loads? What I mean is the CharacterAdded event. (CharacterAdded:Wait()) TheeDeathCaster 2368 — 8y
0
TheeDeathCaster has a point. Unless theevanegps2 has CharacterAutoLoads disabled. Programical 653 — 8y
0
There's no need for that. RubenKan 3615 — 8y
Ad

Answer this question