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

How do I change a player's walk speed after equipping a speed perk?

Asked by 7 years ago

I want the player to equip the speed perk and gain the speed boost, but its not applying the boost. What am I doing wrong?

EquipButton.MouseButton1Down:connect(function()
    if InventoryItemImage.Image == "rblxassetid://769111505" then
        local HumanoidSpeed = game.Players.LocalPlayer.Humanoid.WalkSpeed
        if wins.Value >= 50 then
            HumanoidSpeed = HumanoidSpeed * 2
        elseif wins.Value >= 45 then
            HumanoidSpeed = HumanoidSpeed * 1.9
        elseif wins.Value >= 40 then
            HumanoidSpeed = HumanoidSpeed * 1.8
        elseif wins.Value >= 35 then
            HumanoidSpeed = HumanoidSpeed * 1.7
        elseif wins.Value >= 30 then
            HumanoidSpeed = HumanoidSpeed * 1.6
        elseif wins.Value >= 25 then
            HumanoidSpeed = HumanoidSpeed * 1.5
        elseif wins.Value >= 20 then
            HumanoidSpeed = HumanoidSpeed * 1.4
        elseif wins.Value >= 15 then
            HumanoidSpeed = HumanoidSpeed * 1.3
        elseif wins.Value >= 10 then
            HumanoidSpeed = HumanoidSpeed * 1.2
        elseif wins.Value >= 5 then
            HumanoidSpeed = HumanoidSpeed * 1.1
        end
    end
end)

Also, there error says this:

19:31:04.536 - Humanoid is not a valid member of Player

If Humanoid is not a valid member of players, then what controls the Health, Jump Power, and Walk Speed?

2
Because Humanoid isn't a member of a player. It's a member of a player's character. ScriptGuider 5640 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

You need to access the character by:

game.Players.LocalPlayer.Character

not just by:

game.Players.LocalPlayer
0
Oh ok, I'll try. marioblast1244 113 — 7y
0
Sorry, but it still doesn't work marioblast1244 113 — 7y
Ad

Answer this question