I'm trying to create a hold shift to sprint script. But when I try to get the player's character it gives the error that's in the title. Here's the code:
--Local script local UIS = game:GetService("UserInputService") local player = game.Players.LocalPlayer local char = player.Character local hum = player.Character:FindFirstChild("Humanoid") local held = false UIS.InputBegan:Connect(function(input, gameProcessedEvent) if input.KeyCode == Enum.KeyCode.LeftShift then held = true end while held == true do wait() hum.WalkSpeed = 60 end end) UIS.InputEnded:Connect(function(input, gameProcessedEvent) if input.KeyCode == Enum.KeyCode.LeftShift then held = false end end)
You need to wait for the character to load in first.
Replace
local char = player.Character
with
local char = player.Character or player.CharacterAdded:Wait()