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

im making a game where if you click three things a door opens and the script wont work. why?

im making a game where if you click three things a door opens and the script wont work. ive found where the bug is and its that the if script wont work. anyway here is the code:

here is link https://pastebin.com/gDtz43ew

4 comments

0

That's because it only checks once, and immediately when you start the game.

0

ok but how do you make it check when its been done

0

I'd wrap it in a function and use it within each signal callback for a quick solve.

0

You can also enclose your code in a Lua Code Block, instead of giving a paste in link. Either that or at least make it a hyperlink for convince.

1 answer

✓ Accepted answer

This part is your problem:

if book1 == 2 and leg1 == 2 and thing == 2 then
    game.Workspace.Part1mo.Position = Vector3.new(120.312, 12.125, -19.625)
    wait(5)
    game.Workspace.Part1mo.Position = Vector3.new(120.312, 4.625, -19.625)
    book1 = 1
    leg1 = 1
    thing = 1
end

It only runs once, you would have to run that code block every time one of the ClickDetectors is triggered. You could do that by wrapping it into a function like so:

function CheckStatus()
	if book1 == 2 and leg1 == 2 and thing == 2 then
	    game.Workspace.Part1mo.Position = Vector3.new(120.312, 12.125, -19.625)
	    wait(5)
	    game.Workspace.Part1mo.Position = Vector3.new(120.312, 4.625, -19.625)
	    book1 = 1
	    leg1 = 1
	    thing = 1
	end
end

And then add this function to the click detectors as follows:


script.Parent.MouseClick:Connect(function()
    thing = 2
    CheckStatus()
end)
 
book.ClickDetector.MouseClick:Connect(function()
    book1 = 2
    CheckStatus()
end)
 
leg.ClickDetector.MouseClick:Connect(function()
    leg1 = 2
    CheckStatus()
end)

1 comment

0

thanks this is very helpful

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