Am making a tycoon gives me nil values error?
So, i am making a new tycoon where you have a gui and but stuffs not walk on buttons and i cant get this to work it gives me an nil value error and i dont know why heres the error
1 | 17 : 29 : 22.854 - Players.ObStactionD 3 stroy 3 r.PlayerGui.tycoonUI.frameTycoon.storeFolder.storeTycoon.base_item.buttonPurchase.buttonDriverTycoon: 22 : attempt to index global 'tycoon' (a nil value) |
2 | 17 : 29 : 22.854 - Stack Begin |
3 | 17 : 29 : 22.855 - Script 'Players.ObStactionD3stroy3r.PlayerGui.tycoonUI.frameTycoon.storeFolder.storeTycoon.base_item.buttonPurchase.buttonDriverTycoon' , Line 22 - global onClick |
4 | 17 : 29 : 22.855 - Script 'Players.ObStactionD3stroy3r.PlayerGui.tycoonUI.frameTycoon.storeFolder.storeTycoon.base_item.buttonPurchase.buttonDriverTycoon' , Line 52 |
And heres the script.
02 | item = script.Parent.Parent |
03 | itemType = item.itemType.Value |
04 | itemCost = item.itemCost.Value |
05 | itemID = item.itemID.Value |
06 | itemLocation = tostring (item.itemLocation.Value) |
07 | itemName = tostring (item.itemName.Value) |
08 | script.Parent.Parent.textName.Text = tostring (itemName).. ' | ' .. tostring (itemCost).. ' Cash' |
11 | player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent |
13 | cash = player.stats.Cash.Value |
15 | tycoon = game.Workspace:FindFirstChild( "tycoon_" .. player.Name) |
19 | if cash > = itemCost then |
20 | itemGrab = tycoon.tycoonPurchases:FindFirstChild(itemLocation) |
21 | itemGrab.isPurchased.Value = true |
23 | script.Parent.Parent.isItemPurchased.Value = true |
25 | script.Parent.Text = "Not Enough Funds" |
27 | script.Parent.Text = 'Purchase' |
29 | elseif itemtype = = 2 then |
33 | elseif itemtype = = 3 then |
41 | if script.Parent.Parent.isItemPurchased.Value = = true then |
42 | script.Parent.Text = "Purchased" |
46 | script.Parent.Parent.isItemPurchased.Changed:connect(isPurchased) |
48 | script.Parent.MouseButton 1 Click:connect( function () |
49 | if script.Parent.Parent.isItemPurchased.Value = = false then |