What does this error mean

if PlayerWhoAssited ~= nil and PlayerWhoAssited ~= '' and PlayerWhoAssited ~= PlayerWhoScored then
	if game.Players:FindFirstChild(PlayerWhoAssited) ~= nil and tonumber(game.Players:FindFirstChild(PlayerWhoAssited):GetAttribute("Coins")) ~= nil then -- Line 630
		game.Players:FindFirstChild(PlayerWhoAssited):SetAttribute('Coins', game.Players:FindFirstChild(PlayerWhoAssited):GetAttribute('Coins') + money)
	end
end

BTW, this is line 630 (where it errors):

if game.Players:FindFirstChild(PlayerWhoAssited) ~= nil and tonumber(game.Players:FindFirstChild(PlayerWhoAssited):GetAttribute("Coins")) ~= nil then 

Why does it error? What am I missing? Will it check for the second value even if the first value is already found the be not true?

Because I know that sometimes their will not be an assisting player, so it will be game.PlayersFindFirstChild(PlayerWhoAssited) which is probably the missing argument???

The error is likely coming from:

tonumber(game.Players:FindFirstChild(PlayerWhoAssited):GetAttribute("Coins"))

If the player doesn’t have a Coins attribute or if the attribute is nil, then tonumber will error because void is being passed to it

2 Likes

How would I check and make sure that the player has a Coins attribute?

if not Player:GetAttribute("Coins") then
    Player:SetAttribute("Coins", 0) -- default number of coins
end

Would adding a check for this statement right before also work?

game.Players:FindFirstChild(PlayerWhoAssited):GetAttribute("Coins") ~= nil
1 Like

Yes, it will only error if you were trying to send it as a function’s argument

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.