function onClicked(playerWhoClicked) local movingPart = workspace.Dropper movingPart.Position = movingPart.Position + Vector3.new(0,0.5,0) end script.Parent.ClickDetector.MouseClick:connect(onClicked)
so right now if you click the button the part moves up 0.5 studs but thats not that big of a measurement and so it take a long time to move the part to where its supposed to be and i know i could just make it move up by five studs or something . i dont know how to explain it but in the game you have to navigate through a mase without touching the walls or else you have to restarts right? well lets say it had to go up 6.5 studs then there is a wall right? well if it moved up five studs then it would run into the wall but if i had it at 0.5 then it would be fine, and its a pain in the but to spam click thirty times just to move a part up and thats why i need to know how you add a function that repeats itself if you click and hold
Hi there! there is no "real" way in lua to detect holding down a mouse, but we can do something similar when gui or click detectors are involved using the mouse hover leave evernt (there is a diffrent event for gui)
Isholding = true X= -- put how many seconds you want between each raise of the part, or else it will shoot up into the sky. function left() Isholding = false end function onClicked(playerWhoClicked) Isholding = true repeat local movingPart = workspace.Dropper movingPart.Position = movingPart.Position + Vector3.new(0,0.5,0) wait(x) until Isholding = false end script.Parent.ClickDetector.MouseClick:connect(onClicked) script.Parent.ClickDetector.MouseHoverLeave:Connect(left)
What I did is that I edited you code, and made it loop the raising part, until a variable i made called isholding = false, and is holding is made false when the mouse stops hovering on the click detector. Of course there are some problems with this.
say some one clicks and stops clicking, but their mouse is still hovering, the block will keep raising. But the whole thing will not initiate until you click.
This is the closest i could get