Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would i make it so the persons walkspeed is lower only when they are touching the part?

heres the script:

function onTouch(part)
             local humanoid = part.Parent:FindFirstChild("Humanoid") -- Find humanoid
             if (humanoid ~= nil) then  -- Check for humanoid
                          humanoid.WalkSpeed = 8 
             end
end

script.Parent.Touched:connect(onTouch)

there is no errors but i want it so only when the person is touching the part their walk speed is lowered and when they leave the part their walk speed is back to normal

7 comments

0

It has to be WalkSpeed

0

This isn't a request site; make an attempt

0

He is a noob, he probs doesn't now about touchended dude.

0

slow on the claims dude

0

im a beginner jeez

0

The OP can look up how to detect when a part stops touching a part

0

look, like 50% of mod claims in the past few days are made by you. just slow down

1 answer

✓ Accepted answer

Use touchended:

function onTouch(part)
             local humanoid = part.Parent:FindFirstChild("Humanoid") -- Find humanoid
             if (humanoid ~= nil) then  -- Check for humanoid
                          humanoid.WalkSpeed = 8 
             end
end
function TouchEnded(part)
             local humanoid = part.Parent:FindFirstChild("Humanoid") -- Find humanoid
             if (humanoid ~= nil) then  -- Check for humanoid
                          humanoid.WalkSpeed = 16
             end
end

script.Parent.Touched:connect(onTouch)
script.Parent.TouchEnded:Connect(TouchEnded)

This discussion is preserved as it was. New answers, comments, and votes are closed.