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

How do I apply a different WalkSpeed to a Player? [Answered]

Asked by 7 years ago
Edited 7 years ago

I'm trying to make a perk for my game which gives the player +10% WalkSpeed, but it doesn't really work. I don't know how I should change it either, whether it is through inserting a Humanoid into players or using LocalPlayer.character. Here is my code:

EquipButton.MouseButton1Down:connect(function()
    if InventoryItemImage.Image == "rblxassetid://769111505" then
        local HumanoidSpeed = game.Players.LocalPlayer.Character.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)

There also aren't any errors. Any help is appreciated!

0
The problem might be how you spelled the Image ID. You added an "L" in "rblxassetid". It's "rbxassetid" Mayk728 855 — 7y
0
You defined the player's WalkSpeed on line 3, and not the player's WalkSpeed to be editied; to fix this, simply remove WalkSpeed from line 3, then set it to the following HumanoidSpeed variables; really, this is the only way to accomplish this. ;/ TheeDeathCaster 2368 — 7y
0
Oh, thanks for the info! marioblast1244 113 — 7y
0
Does it have to be in a LocalScript? marioblast1244 113 — 7y
View all comments (2 more)
0
Nevermind, it works. Thanks for the help both of you! marioblast1244 113 — 7y
0
Np. ;P TheeDeathCaster 2368 — 7y

Answer this question