So, I want the script to act this way; when the player touched the part, his movement speed is decreased by 4 until the player stops touching the block. When the player stops touching the block his speed goes back to normal. Do you have any idea how to make this happen? Thanks!
local debounce = false
function onTouched(hit)
if debounce == true then return end
debounce = true
hit.Parent.Humanoid.WalkSpeed = hit.Parent.Humanoid.WalkSpeed - 4
repeat until
script.Parent.TouchEnded:connect(onTouched)
hit.Parent.Humanoid.Walkspeed = hit.Parent.Humanoid.WalkSpeed + 4
debounce = false
end
script.Parent.Touched:connect(onTouched)

3 comments
First, take out line 7 entirely. Second, replace "connect" on line 8 with "wait" and take out onTouched (and try "Wait", I don't know if it needs to be capitalized).
Sorry it didn't work for me. I removed line 7, and for line 8 I replaced "connect" with "wait". Also I removed "onTouched" on line 8.
Try my script again, I have edited the problem out.