Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Can someone help me with my scripts?

Asked by 8 years ago
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

2 answers

Log in to vote
0
Answered by 8 years ago

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)

0
I cannot do that because the first code is a button and the second is the dropper SamKillz123 5 — 8y
0
@SquirrelOnToast SamKillz123 5 — 8y
0
For instance... the ore comes down the conveyor.. touches the little whatever and it is deleted but adds 1 to the 'IronStored' then you push a button and it then drops an ore but also removes 1 from the 'IronStored' value. do you get it? SamKillz123 5 — 8y
0
Not true. By my eye, those 2 scripts can be merged quite easily. SquirreIOnToast 309 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
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.

Answer this question