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,

2 comments
The Price value needs to be either a NumberValue or an IntValue. Make sure it is not a SringValue.
I have made it into a number value but I still get the same error and it was also an IntValue before I changed it to number value.