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

Output tells me that there is an error in a BotKicker Script?

Asked by
GUN1FY 4
4 years ago
Edited 4 years ago

Hey there! As we ROBLOX Players know: There are Bots. MANY Bots. So I wanted to deliver the best experience to my Server Players and made a BotKicker in ServerScriptService as a Script. Now when I attempt to play the Game inside of ROBLOX Studio it says following:

ServerScriptService.BotKicker:5: attempt to index nil with "AccountAge"

Now I went trough the script and couldn't find a reason for this to happen. The script:

local minimumAge = 15
local kickMessage = "Sorry, but your Account must be atleast 15 days old to join this game. Please use an account that is over 15 days old and try again."

game.Players.PlayerAdded:Connect(function()
    if player.AccountAge < minimumAge then
        player:Kick(kickMessage)
    end
end)

I hope somebody can help me with this :/ Have a nice day!

0
on line 4 player is nil, you should do game.Players.PlayerAdded:Connect(function(player) kepiblop 124 — 4y
0
Okay, Thank you so much! :D GUN1FY 4 — 4y

1 answer

Log in to vote
0
Answered by
TheePBHST 154
4 years ago

In,

game.Players.PlayerAdded:Connect(function()

You need to add "player" between the paraenthesis after function.

You need to specify the argument that is returned by the PlayerAdded event.

0
Okay, Thank you so much! :D But didn't i specify the argument by Players.PlayerAdded? GUN1FY 4 — 4y
Ad

Answer this question