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

How could i get around this walkspeed issue?

Asked by
Nogalo 148
7 years ago

So i've made an obby and in one of the levels at the start your walkspeed is set to 74 and you have to finish the whole level at that speed then at the end there is a slowdown that sets your speed to the default 16.This was all fine and well until i've introduced gamepasses into the game, some of them increase the speed of the player. So my question is how would i make it so that at the end of the level your speed is set to what ever it was before you started the level and your speed was set to 74?

this is the script at the start of the level, the one at the end is basicly the same but with different speed

local SpeedBoost = script.Parent

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

SpeedBoost.Touched:connect(steppedOn)

I've adding scripts inside all parts of the level so that while the player is touching them his speed is 74 and then when he completes the level his speed is set to what it was, but if you have any cleaner and more effective solutions i'm all ears.

Thanks for your time.

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago
local SpeedBoost = script.Parent

SpeedBoost.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid.WalkSpeed = 74
    end
end

this will work

0
this has absolutely nothing to do with my question Nogalo 148 — 7y
0
Oh my bad. I misunderstood the question than dallylogan 29 — 7y
0
Are you having an issue with checking for gamepasses on players or what is the issue? Are the gamepasses not letting the players speed go back to normal or something? dallylogan 29 — 7y
Ad

Answer this question