Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by 4 years ago
Edited 4 years ago

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

0
It has to be WalkSpeed Skydoeskey 108 — 4y
0
This isn't a request site; make an attempt hiimgoodpack 2009 — 4y
0
He is a noob, he probs doesn't now about touchended dude. BashGuy10 384 — 4y
0
slow on the claims dude BashGuy10 384 — 4y
View all comments (3 more)
0
im a beginner jeez Toastitions 11 — 4y
0
The OP can look up how to detect when a part stops touching a part hiimgoodpack 2009 — 4y
0
look, like 50% of mod claims in the past few days are made by you. just slow down BashGuy10 384 — 4y

Closed as Not Constructive by hiimgoodpack, BashGuy10, and pwx

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 4 years ago

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)
Ad