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

Is it possible to make a change in the player’s speed when he got off from part?

Asked by 4 years ago

I have such a script in part:

local part = script.parent

local function steppedOn(part)
    local parent = part.Parent
    if game.Players:GetPlayerFromCharacter(parent) then
        parent.Humanoid.WalkSpeed = 60
    end
end

part.Touched:connect(steppedOn)

Is it possible to do when the player got off the part, his WalkSpeed parameter changed to the initial one 16? If possible, then how?

0
Use TouchedEnded. XviperIink 428 — 4y
0
Thanks. I will test tomorrow. LioshaPlay 66 — 4y

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
4 years ago

XviperIink said, use TouchedEnded. I'll tell some more thing, you can do the script like this, I have nothing to describe from this, but something ill say.

You can do else from the function if there have no more speed changers. You know how else work, right? So you can fix the problem with this shortcut.

But I'll make the highest recommendation script that's if there have speed changers or no, you also can copy & paste to inside.

There some issues. The humanoid did not exist while are at building mode, as known that not a running mode or testing, or playing mode. So, make :FindFirstChild().

More descriptions was at the script.

local part = script.parent

-- If there any problems in the script, then remove the '--' below this comment (remove my below 2 lines.)

-- part.Anchor = true
-- part.CanCollide = false

local function steppedOn(function(plr) -- plr means for player
    if h then
            parent.FindFirst("Humanoid").WalkSpeed = 60
        end
end

local function steppedOff(function(plr)
    if h then
        parent.FindFirstChild("Humanoid").WalkSpeed = 16
    end
end

part.Touched:Connect(steppedOn)
part.TouchedEnded:Connect(SteppedOff)

-- done!

Hey, we did it!

If you have more problems, comment in the below, ill cya later, bye bye~~~~~~~ :D

Ad

Answer this question