Hi, so I am making a tycoon and I have ran into a problem with a script for my buy button here is the code
repeat wait() until script.Parent.Product.Value ~= nil local product = script.Parent.Product.Value:clone() script.Parent.Product.Value:Remove() price = script.Parent.Price.Value script.Parent.Head.Touched:connect(function(hit) local char = hit.Parent if char:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(char) then local plr = game.Players:GetPlayerFromCharacter(char) if plr.Name == script.Parent.Parent.Parent.OwnerName.Value and plr.leaderstats.Money.Value >= price.Value then plr.leaderstats.Money.Value = plr.leaderstats.Money.Value - price product.Parent = script.Parent.Parent.Parent end end end)
and here is the error
14:48:39.733 - Workspace.Tycoon.Purchasing.Purchase - Price.Script:10: attempt to index global 'price' (a number value) 14:48:39.734 - Stack Begin 14:48:39.734 - Script 'Workspace.Tycoon.Purchasing.Purchase - Price.Script', Line 10 14:48:39.734 - Stack End
I have tried to fix this but I have had no luck whatsoever so I will be very thankful to anyone who can help me,
Price is not an instance that has a Value property.
price = script.Parent.Price.Value
Which is why you can't acces it.
price.Value
Change line 10 to this.
if plr.Name == script.Parent.Parent.Parent.OwnerName.Value and plr.leaderstats.Money.Value >= price then