#Localscript refusing to run

1 messages · Page 1 of 1 (latest)

opaque plaza
#

Title says it all. This local script I've created for player sprinting is refusing to run, I've tried the print method to make sure and there's no output related to it not working. Any help would be greatly appreciated. . .

local player = game:GetService("Players").LocalPlayer
local character = player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local ConService = game:GetService("ContextActionService")
local UserService = game:GetService("UserInputService")

local normalWalkSpeed = 16
local sprintSpeed = 20

local leftC = Enum.KeyCode.LeftControl
local rightC = Enum.KeyCode.RightControl

--Sprinting
UserService.InputBegan:Connect(function(input, gameProcessedEvent)
    if input.KeyCode == Enum.KeyCode.LeftShift then
        humanoid.WalkSpeed = sprintSpeed
    end
end)

UserService.InputEnded:Connect(function(input, gameProcessedEvent)
    if input.KeyCode == Enum.KeyCode.LeftShift then
        humanoid.WalkSpeed = normalWalkSpeed
    end
end) --PC

local function handleContext(name, state, input)
    if state == Enum.UserInputState.Begin then
        humanoid.WalkSpeed = sprintSpeed
    else
        humanoid.WalkSpeed = normalWalkSpeed
    end
end

ConService:BindAction("Sprint", handleContext, true, leftC, rightC)
ConService:SetPosition("Sprint", UDim2.new(0.2, 0, 0.5, 0))
ConService:SetTitle("Sprint", "Sprint")
ConService:GetButton("Sprint").Size = UDim2.new(0.3, 0, 0.3, 0) --Mobile```
somber marten
opaque plaza
somber marten