So i made a sprint script that has a sprinting animation play while pressing shift. It works fine in studio but when i took it to live game, i got the error in the Question title (on lines 7 and 17)
here is the code
local UIS = game:GetService('UserInputService')
local player = game.Players.LocalPlayer
local character = player.Character
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
character.Humanoid.WalkSpeed = 32
local anim = Instance.new('Animation')
anim.AnimationId = 'rbxassetid://01516599081'
playAnim = character.Humanoid:LoadAnimation(anim)
playAnim:Play()
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
character.Humanoid.WalkSpeed = 16
playAnim:Stop()
end
end)
Im not sure why it cant seem to find character? but in studio it does?

2 comments
try: repeat wait() until player.Character
i have already tried that, thank you though.