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!

6 comments

0

The problem might be how you spelled the Image ID. You added an "L" in "rblxassetid". It's "rbxassetid"

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. ;/

0

Oh, thanks for the info!

0

Does it have to be in a LocalScript?

0

Nevermind, it works. Thanks for the help both of you!

0

Np. ;P