Currently this is how its set up rn its a place holder but it just doesn’t work how would i fix it, its in starter character scripts
-- Services
local input = game:GetService("UserInputService")
local player = game:GetService("Players")
-- Variables
local player = player.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local humaniod = character:FindFirstChild("Humanoid")
-- Speeds
local walkSpeed = 14
local sprintSpeed = 28
local state = "walk"
local rolling = false
local rollDebounce = false
local rollTime = 1
-- Sprinting
input.InputBegan:Connect(function (key)
if key.KeyCode == Enum.KeyCode.LeftShift then
if humaniod then
character.Humanoid.WalkSpeed = sprintSpeed
state = "sprint"
end
end
end)
input.InputEnded:Connect(function (key)
if key.KeyCode == Enum.KeyCode.LeftShift then
if humaniod then
character.Humanoid.WalkSpeed = walkSpeed
state = "walk"
end
end
end)
-- Rolling
input.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.C and state == "sprint" and rollDebounce == false then
if humaniod then
print("roll")
rollDebounce = true
rolling = true
task.wait(rollTime)
rolling = false
rollDebounce = false
end
end
end)
-- Crouching
input.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.C and state == "walking" then
if humaniod then
local attachment = Instance.new("Attachment" , humaniod)
local force = Instance.new("VectorForce" , humaniod)
force.Attachment0 = attachment
force.Force = (Vector3.new(0,1,0)).Unit * 10000
force.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
end
end
end)