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

Click detection doesn't do anything with my toggled conveyor. What is wrong?

-- sdd is the part where I want the texture to change and ConveyorRG is what I want for the velocity to be changed.

  

local works = false

  

script.Parent.Button.ClickDetector.MouseClick:Connect(function()

if works == false then

works = true

Parent.ConveyorRG.Velocity = Vector3.new(0,0,-1.4)

Parent.ConveyorRG.CanCollide = false

repeat

wait()

Parent.sdd.Texture.Texture = "http://www.roblox.com/asset/?id=265668762" --2

if frontdown == false then break end

wait()

Parent.sdd.Texture.Texture = "http://www.roblox.com/asset/?id=265668788" --3

if frontdown == false then break end

wait()

Parent.sdd.Texture.Texture = "http://www.roblox.com/asset/?id=265668797" --4

if frontdown == false then break end

wait()

Parent.sdd.Texture.Texture = "http://www.roblox.com/asset/?id=265668806" --5

if frontdown == false then break end

wait()

Parent.sdd.Texture.Texture = "http://www.roblox.com/asset/?id=265668810" --6

if frontdown == false then break end

wait()

Parent.sdd.Texture.Texture = "http://www.roblox.com/asset/?id=265668819" --7

if frontdown == false then break end

wait()

Parent.sdd.Texture.Texture = "http://www.roblox.com/asset/?id=265668834" --8

if frontdown == false then break end

wait()

Parent.sdd.Texture.Texture = "http://www.roblox.com/asset/?id=265668847" --9

if frontdown == false then break end

wait()

Parent.sdd.Texture.Texture = "http://www.roblox.com/asset/?id=265668856" --10

if frontdown == false then break end

wait()

Parent.sdd.Texture.Texture = "http://www.roblox.com/asset/?id=265668870" --11

if frontdown == false then break end

wait()

Parent.sdd.Texture.Texture = "http://www.roblox.com/asset/?id=265668877" --12

if frontdown == false then break end

wait()

Parent.sdd.Texture.Texture = "http://www.roblox.com/asset/?id=265668884" --13

if frontdown == false then break end

wait()

Parent.sdd.Texture.Texture = "http://www.roblox.com/asset/?id=265668745" --1

until frontdown == false

end

end)

1 answer

local works = false
ClickDetector.MouseClick:Connect(function()
    if (not works) then
	    works = true
	    --stuff
	    works = false
    end
end)

You need to set the variable works to false if you want it to run again. Otherwise it'll only work for the first click (assuming you want it to work multiple times).

Error codes would help us with the solution and context of your situation.

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