Any Errors in the Output That you can Find?
This should be player.Character or player.CharacterAdded:Wait()
!
I personally find using one script for a sprint script better, I use a module just to wrap simple key down/up actions with UserInputService, and this ends up being my code:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local KeyInputService = require(ReplicatedStorage.Utils.KeyInputService)
local LocalPlayer = Players.LocalPlayer
local PlayerCharacter = LocalPlayer.Character
LocalPlayer.CharacterAdded:Connect(function(character: Model)
PlayerCharacter = character
end)
KeyInputService.ConnectToKeyCode(Enum.KeyCode.LeftShift, function(isBegin)
if PlayerCharacter == nil then
return
end
local humanoid = PlayerCharacter:FindFirstChild("Humanoid")
if humanoid then
humanoid.WalkSpeed = isBegin and 22 or 16
end
end)
4 Likes
Instead of wait, use task.wait(), its more officiant and useful and its more modern and reliable.