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 9 years ago
1local ClickDetector = Instance.new("ClickDetector", script.Parent)
2local Drop = script.Parent.Parent.Drop
3 
4ClickDetector.MouseClick:connect(function()
5    Drop.Value = true
6end)
01local Drop = script.Parent.Parent.Drop
02local IronStored = script.Parent.Parent.IronStored
03 
04if Drop == true then
05    if IronStored.Value > 0 then
06        local IronOre = Instance.new("Part",game.Workspace)
07        IronOre.Name = "IronOre"
08        IronOre.Size = Vector3.new(1, 1, 1)
09        IronOre.TopSurface = 0
10        IronOre.BottomSurface = 0
11        local OreValue = Instance.new("NumberValue",game.Workspace.IronOre)
12        OreValue.Name = "Price"
13        IronOre.Price.Value = 5
14        IronStored.Value = ValueStored.Value - 1
15        Drop = false
16    end
17else
18    Drop = false
19end

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 9 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:

1local ClickDetector = Instance.new("ClickDetector", script.Parent)
2local Drop = script.Parent.Parent.Drop
3 
4ClickDetector.MouseClick:connect(function()
5    --DUMP CODE HERE
6end)
0
I cannot do that because the first code is a button and the second is the dropper SamKillz123 5 — 9y
0
@SquirrelOnToast SamKillz123 5 — 9y
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 — 9y
0
Not true. By my eye, those 2 scripts can be merged quite easily. SquirreIOnToast 309 — 9y
Ad
Log in to vote
0
Answered by 9 years ago
01local Drop = script.Parent.Parent.Drop
02local IronStored = script.Parent.Parent.IronStored
03Drop.Changed:connect(function()
04    if Drop.Value then
05if Drop.Value == true then
06    if IronStored.Value > 0 then
07        local IronOre = Instance.new("Part",game.Workspace)
08        IronOre.Name = "IronOre"
09        IronOre.Size = Vector3.new(1, 1, 1)
10        IronOre.TopSurface = 0
11        IronOre.BottomSurface = 0
12    IronOre.Position = script.Parent.Position + Vector3.new(0,5,0)
13        local OreValue = Instance.new("NumberValue",game.Workspace.IronOre)
14        OreValue.Name = "Price"
15        OreValue.Value = 5
View all 23 lines...

That works for me.

Answer this question