Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

3 comments

0

why do you have did you made a player variable if you already had the parameter?

0

why do you have did you made a player variable if you already had the parameter?

0

i think you should delete the player variable

2 answers

✓ Accepted answer

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!

1 comment

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

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.

1 comment

0

indeed

This discussion is preserved as it was. New answers, comments, and votes are closed.