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

How come my kick isn't working when the player isn't in the correct age?

Asked by 3 years ago

I'm making this to where it kicks the player when they're not in that certain age. It's not kicking the player, how come?

function OnEntered(Player)
    if Player.AccountAge <= 20 then
        local Player = game.Players:GetPlayerFromCharacter(Player.Parent)
        Player:Kick("Your account must be 20 days old to play.")
    end
end

game.Players.PlayerAdded:connect(OnEntered)
0
why do you have did you made a player variable if you already had the parameter? 0Papa_Rat0 63 — 3y
0
why do you have did you made a player variable if you already had the parameter? 0Papa_Rat0 63 — 3y
0
i think you should delete the player variable 0Papa_Rat0 63 — 3y

2 answers

Log in to vote
3
Answered by 3 years ago

SoftlockedUnderZero is right. You should only do:

function OnEntered(Player)
    if Player.AccountAge < 20 then
        Player:Kick("Your account must be 20 days old to play.")
    end
end

game.Players.PlayerAdded:Connect(function(OnEntered)

Hope this helps!

0
I wish I can accept both answers... Idk what I was thinking. I knew something was wrong when I made this last night. Thanks for the help SoftlockedUnderZero and krowten024nabrU TheBuliderMC 84 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Why line 3? It doesn't make sense. What's your intention with line 3? Only the Player Instance has the kick function, not the model.

I suggest you remove line 3, because the player variable is already given to you.

0
indeed 0Papa_Rat0 63 — 3y

Answer this question