Alright. I'm trying to make a block that slows you down while you're inside it, but gives you normal speed when you leave it. But for some reason, after making it so your walkspeed doesn't go infinitely high, it doesn't work at all. I added a print every other line starting in the functions, and it doesn't get past the line 5 print for some reason. I need this to work with custom speeds (which is why it uses division and multiplication) so don't suggest making the numbers fixed.
touched = false
function touched(hit)
if hit.Parent:FindFirstChild("Humanoid") and touched == false then
print("line 5")
touched = true
print("line 7")
hit.Parent.Humanoid.WalkSpeed = hit.Parent.Humanoid.WalkSpeed / 2
print("line 9")
end
end
function touchended(hit)
if hit.Parent:FindFirstChild("Humanoid") and touched == true then
print("line15")
hit.Parent.Humanoid.WalkSpeed = hit.Parent.Humanoid.WalkSpeed * 2
print("line17")
touched = false
print("line19")
end
end
script.Parent.Touched:connect(touched)
script.Parent.TouchEnded:connect(touchended)
I literally have no idea what's wrong with this and I am extremely confused and frustrated.

3 comments
Works fine for me after changing the function name. Thanks for telling me it was connecting to the variable - I thought it would know which one was the variable and which one was the function.
i thought so too. but we both learned something today
Good job. Was gonna solve it myself, but looks like someone beat me to it.:)