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

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

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?

2 comments

0

Use TouchedEnded.

0

Thanks. I will test tomorrow.

1 answer

✓ Accepted answer

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

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