I can't seem to make players in my game sprint when they have a sword equipped, specifically when they press "E". I'll post the code that I have below, any help would be greatly appreciated!
sword = game.StarterPack.ClassicSword
sword.Equipped:Connect(function()
local player = game.Players.LocalPlayer
local character = player.Character
local UserInputService = game:GetService("UserInputService")
local eHeld = UserInputService:IsKeyDown(Enum.KeyCode.E)
if eHeld == true then
character.Humanoid.WalkSpeed = 20
elseif eHeld == false then
character.Humanoid.WalkSpeed = 16
end
end)

1 comment
Get the backpack of the localplayer not starterpack, I'll make an answer for it right now