I want an NPC that stops moving when it touches a part of a gear, and when its not touching it moves fast again. The block I want it to slow down on is called "detect"
slow = true
script.Parent.Touched:Connect()(function(hit)
if hit.Parent:FindFirstChild("detect") then
script.Parent.Humanoid.WalkSpeed = 0
slow = false
end
end)
if slow = true
script.Parent.Humanoid.WalkSpeed = 0
else
if slow = false
script.Parent.Humanoid.WalkSpeed = 32
end

1 comment
You forgot to add "then" in the end of line 10 and 13.