I created an part which when touched by another, it checks if it is a tycoon part or not, and if yes, it will increase it's value.
Here's the script i am using:
script.Parent.Touched:connect(function(h) if h:FindFirstChild("Money Value") and h.Reflectance == 0 then -- this last argument is to prevent multiple increases of the same part h["Money Value"].Value = h["Money Value"].Value * 1.5 + 1 h.Reflectance = 0.3 print ("Success!! Now the part values "..h["Money Value"].Value) else print ("???") end end)
It worked, until I added a buy button to it. It does not do anything to the parts who touch it. Nothing in the ouput, no success or failure message. But when i touch that part with my character, it prints the failure message. Why? (Below, the script who generates the tycoon parts:)
PartsPerMinute = script.Parent["Parts Per Minute"] MValue = script.Parent["Initial Part Value"] SCh = script.Parent["Storage Charge Every Drop"] function Drop(money, storagecharge) if script.Parent.Parent.Parent.MineralProducer.MineStorage.Value >= storagecharge then local Part = game.ServerStorage.MineralInstances.CopperS:Clone() Part.Position = script.Parent.Position - Vector3.new(0,0.5,0) Part.Parent = script.Parent local Val = Instance.new("NumberValue") Val.Parent = Part Val.Value = money Val.Name = "Money Value" script.Parent.Parent.Parent.MineralProducer.MineStorage.Value = script.Parent.Parent.Parent.MineralProducer.MineStorage.Value - storagecharge end end while true do wait (60/PartsPerMinute.Value) Drop(MValue.Value, SCh.Value) end