I want to know how to make a "while touched" script.
So when a player is touching a brick, it will execute a function, but I also want it were the function will always execute intill the player steps off the brick.
So I want a loop when you are touching and i want the loop to end when you stop touching
thank you for any type of help!
local block = script.Parent on = true function touching() print ('Touching!') end function notTouching() print ('Not Touching!') end block.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and on == true then --we put this so if item fall in there or the part touching to the ground it will not activated touching() wait (3) on = false end end) block.TouchEnded:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and on == false then --same like this one notTouching() wait (3) on = true end end)
i put the comparing variable so it will not spamming printing until 3 second ,sorry if i wrong im still learning too :)