How to check a value in the player?
Asked by
3 years ago Edited 3 years ago
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)
01 | game.Players.PlayerAdded:Connect( function (player) |
02 | local Inventory = Instance.new( "Folder" ) |
03 | Inventory.Parent = player |
04 | Inventory.Name = "Inventory" |
06 | local Log = Instance.new( "IntValue" ) |
07 | Log.Parent = Inventory |
The Code that is causing errors (LocalScript in InvGUI which is in StarterGUI)
1 | script.Parent.MouseButton 1 Click:Connect( function (player) |
2 | local logamount = player.Inventory.Log |
3 | if logamount.Value > = 5 then |
4 | print (player.Name "Has 5 or more then 5 logs" ) |
6 | print (player.Name "Has less than 5 logs" ) |