I'm making a thing where i t makes a folder called Inventory inside the player and a intValue called Log and when they click this button it checks if they have 5 or more logs it prints the player name has 5 or more logs but it didnt work Instead i got a error: Players.googlpeopel15.PlayerGui.InvGUI.Frame.LogWall.PurchaseHandler:3: attempt to index nil with 'Inventory' - Client - PurchaseHandler:3 12:15:33.742
Here is Inventory adding code. (Server script in ServerScriptService)
game.Players.PlayerAdded:Connect(function(player)
local Inventory = Instance.new("Folder")
Inventory.Parent = player
Inventory.Name = "Inventory"
local Log = Instance.new("IntValue")
Log.Parent = Inventory
Log.Value = 0
Log.Name = "Log"
end)
The Code that is causing errors (LocalScript in InvGUI which is in StarterGUI)
script.Parent.MouseButton1Click:Connect(function(player)
local logamount = player.Inventory.Log
if logamount.Value >= 5 then
print(player.Name "Has 5 or more then 5 logs")
else
print(player.Name "Has less than 5 logs")
end
end)

2 comments
True, MouseButton1Click has no paramaters.
Thanks for the confirmation, I wasn't too sure