Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can someone help me with my scripts?

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

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)

4 comments

0

I cannot do that because the first code is a button and the second is the dropper

0

@SquirrelOnToast

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?

0

Not true. By my eye, those 2 scripts can be merged quite easily.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.