I know how to do something when you step on a part (
function onTouch(hit) -- hit is what I always put so I can do local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Put code here bla bla bla end script.Parent.Touched:connect(onTouch)
) But I want to know how you can do something for the duration of while somebody is stepping on the part then do something else when they step off.
If you could help I would appreciate it!
TouchEnded is an event of parts that you can add to the onTouch function like so:
function onTouchEnded(hit) --stuff end function onTouch(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) --stuff script.Parent.TouchEnded:connect(onTouchEnded) end script.Parent.Touched:connect(onTouch)