How should I change this script to suit the function of allowing others to buy it? The aim is that you produce a material, and then others buy that for a set price. How do you think I should do it?
repeat wait() until script.Parent.Product.Value~=nil
local product=script.Parent.Product.Value:Clone()
script.Parent.Product.Value:remove()
local price=script.Parent.Price.Value
script.Parent.Name=script.Parent.ProductName.Value.." - "..price --sets name of brick
if price==0 then
script.Parent.Name=script.Parent.ProductName.Value.." - FREE"
end
script.Parent.Head.Touched:connect(function(hit) --this is how people buy it
chr=hit.Parent
plr=game.Players:GetPlayerFromCharacter(chr)
if chr:findFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(chr) and plr.leaderstats.Money.Value>=price then
if plr.Name==script.Parent.Parent.Parent.OwnerName.Value then
plr.leaderstats.Money.Value=plr.leaderstats.Money.Value-price
product.Parent=script.Parent.Parent.Parent
script.Parent:remove()
end
end
end)
