Hello,
I’m having problems with my sprint module, it’s very simple and it should work but it isn’t.
local ContextActionService = game:GetService("ContextActionService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterPlayer = game:GetService("StarterPlayer")
local UserInputService = game:GetService("UserInputService")
local Source = ReplicatedStorage.Source
local Packages = ReplicatedStorage.Packages
local Settings = require(Source.Dependencies.GameSettings)
local Knit = require(Packages.Knit)
local MovementController = Knit.CreateController{
Name = "MovementController",
}
local Player = Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid") :: Humanoid
local ACTION_SLIDE = "Slide"
local ACTION_SPRINT = "Sprint"
local function handleAction(actionName, inputState, _inputObject)
if actionName == ACTION_SLIDE and inputState == Enum.UserInputState.Begin then
print("Sliding")
end
if actionName == ACTION_SPRINT and inputState == Enum.UserInputState.Begin then
if Humanoid.WalkSpeed == StarterPlayer.CharacterWalkSpeed then
Humanoid.WalkSpeed = Settings.Sprint
end
if Humanoid.WalkSpeed ~= StarterPlayer.CharacterWalkSpeed then
Humanoid.WalkSpeed = StarterPlayer.CharacterWalkSpeed
end
end
end
function MovementController.KnitStart()
if Character then
bindActions(true)
end
Player.CharacterAdded:Connect(function(character: Model)
Character = character
end)
end
return MovementController
Also yes, handleAction is already binded, I tested it.
This is in replicatedstorage, thats why I’m using characteradded