1 | local ClickDetector = Instance.new( "ClickDetector" , script.Parent) |
2 | local Drop = script.Parent.Parent.Drop |
3 |
4 | ClickDetector.MouseClick:connect( function () |
5 | Drop.Value = true |
6 | end ) |
01 | local Drop = script.Parent.Parent.Drop |
02 | local IronStored = script.Parent.Parent.IronStored |
03 |
04 | if Drop = = true then |
05 | if IronStored.Value > 0 then |
06 | local IronOre = Instance.new( "Part" ,game.Workspace) |
07 | IronOre.Name = "IronOre" |
08 | IronOre.Size = Vector 3. 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 |
17 | else |
18 | Drop = false |
19 | 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:
1 | local ClickDetector = Instance.new( "ClickDetector" , script.Parent) |
2 | local Drop = script.Parent.Parent.Drop |
3 |
4 | ClickDetector.MouseClick:connect( function () |
5 | --DUMP CODE HERE |
6 | end ) |
01 | local Drop = script.Parent.Parent.Drop |
02 | local IronStored = script.Parent.Parent.IronStored |
03 | Drop.Changed:connect( function () |
04 | if Drop.Value then |
05 | if 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 = Vector 3. new( 1 , 1 , 1 ) |
10 | IronOre.TopSurface = 0 |
11 | IronOre.BottomSurface = 0 |
12 | IronOre.Position = script.Parent.Position + Vector 3. new( 0 , 5 , 0 ) |
13 | local OreValue = Instance.new( "NumberValue" ,game.Workspace.IronOre) |
14 | OreValue.Name = "Price" |
15 | OreValue.Value = 5 |
That works for me.