local ClickDetector = Instance.new("ClickDetector", script.Parent) local Drop = script.Parent.Parent.Drop ClickDetector.MouseClick:connect(function() Drop.Value = true end)
local Drop = script.Parent.Parent.Drop local IronStored = script.Parent.Parent.IronStored if Drop == true then if IronStored.Value > 0 then local IronOre = Instance.new("Part",game.Workspace) IronOre.Name = "IronOre" IronOre.Size = Vector3.new(1, 1, 1) IronOre.TopSurface = 0 IronOre.BottomSurface = 0 local OreValue = Instance.new("NumberValue",game.Workspace.IronOre) OreValue.Name = "Price" IronOre.Price.Value = 5 IronStored.Value = ValueStored.Value - 1 Drop = false end else Drop = false end
Which script is wrong? How do i fix it? its supposed to be storage a storage system for my 'Iron Ore'. Any and all answers are greatly appreciated! Thanks!
-SamKillz123
if Drop == true
only runs once and does not fire when you change the value of Drop
. Take the code and put it inside the original function like so:
local ClickDetector = Instance.new("ClickDetector", script.Parent) local Drop = script.Parent.Parent.Drop ClickDetector.MouseClick:connect(function() --DUMP CODE HERE end)
local Drop = script.Parent.Parent.Drop local IronStored = script.Parent.Parent.IronStored Drop.Changed:connect(function() if Drop.Value then if Drop.Value == true then if IronStored.Value > 0 then local IronOre = Instance.new("Part",game.Workspace) IronOre.Name = "IronOre" IronOre.Size = Vector3.new(1, 1, 1) IronOre.TopSurface = 0 IronOre.BottomSurface = 0 IronOre.Position = script.Parent.Position + Vector3.new(0,5,0) local OreValue = Instance.new("NumberValue",game.Workspace.IronOre) OreValue.Name = "Price" OreValue.Value = 5 IronStored.Value = IronStored.Value - 1 Drop.Value = false end else Drop = false end end end)
That works for me.