This is the script and it works adding speed but breaks when decreasing
01 | local tool = script.Parent |
02 | local Handle = tool:WaitForChild( "Handle" ) |
03 |
04 | tool.Equipped:Connect( function () |
05 | local h = script.Parent.Parent:FindFirstChild( "Humanoid" ) |
06 | h.WalkSpeed = h.WalkSpeed + 20 |
07 | end ) |
08 |
09 | tool.Unequipped:Connect( function () |
10 | local h = script.Parent.Parent:FindFirstChild( "Humanoid" ) |
11 | h.WalkSpeed = h.WalkSpeed - 20 --Here is the problem. It says that walkspeed is not a valid member of Humanoid |
12 | end ) |
01 | local tool = script.Parent |
02 |
03 | if script.Parent.Parent.Name = = "Backpack" then |
04 | character = script.Parent.Parent.Parent.Character |
05 | else |
06 | character = script.Parent.Parent |
07 | end |
08 |
09 | h = character:WaitForChild( "Humanoid" ) |
10 |
11 | tool.Equipped:Connect( function () |
12 | h.WalkSpeed = h.WalkSpeed + 20 |
13 | end ) |
14 |
15 |
16 | tool.Unequipped:Connect( function () |
17 | h.WalkSpeed = h.WalkSpeed - 20 |
18 | end ) |