local Object = "SolarPanel1"
local Price = 10000
local Color = script.Parent.Parent.Parent.Color.Value
local DB = false
script.Parent.Touched:connect(function(buyer)
if buyer.Parent:FindFirstChild("Humanoid") and buyer.Parent:FindFirstChild("Torso") then
if buyer.Parent.Name == script.Parent.Parent.Parent.Owner.Value then
local BMoney = game.Players:FindFirstChild(buyer.Parent.Name).leaderstats.Money.Value
if BMoney >= Price then
DB = true
BMoney = BMoney - Price
game.Lighting:FindFirstChild(Color):FindFirstChild(Object):Clone().Parent = script.Parent.Parent.Parent.Objects
script.Parent:Destroy()
DB = false
end
end
end
end)
So, I'm making a tycoon, and this is the script to purchase items. But for some reason, money isn't taken away from the buyer when it is activated.
Any help?
