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)
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.