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

[Solved] Why doesnt my click detector detect clicks?

Im trying to make a thing where theres an "elevator" and when i click a button it should change some stuff but for some reason it doesnt detect the click.Im really new to coding on roblox and any help is appreciated. Thank you!

Explorer:

https://imgur.com/a/bdUan4u

Code:

local text = script.Parent
local button = text.Parent.Parent.Button
local detector = button.ClickDetector
local floor = text.Floor.Value
print("local stuff")

---------- functionns --------------------


function startElevator()
	print("elevator started")
	floor = -6
	wait(2.1)
	floor = -5
	wait(2)
	floor = -4
	wait(1.7)
	floor = -3
	wait(1.8)
	floor = -2
	wait(2.1)
	floor = -1
	wait(2.4)
	floor = 0
	wait(2.7)
	floor = 1
	wait(3)
end


function onMouseClick()
	print("clicked")
	startElevator()
end


--------- stuff --------------------------


while true do
	wait(0)
    print("update")
    floor = text.Floor.Value
	text.Text = floor
end

detector.MouseClick:connect(onMouseClick)

1 answer

✓ Accepted answer

Your while loop is blocking it from ever giving the MouseClick a function to go to.

Put the 'detector.MouseClick:connect(onMouseClick) above the while loop and it should work.

1 comment

0

THANK YOU!

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