I am currently trying to make a crawl system in a local script
The script is not running the InputBegan event from UserInputService
I have already put multiple prints to check what is the issue.
Script:
local UIS = game:GetService("UserInputService")
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local crawlAnim = hum:LoadAnimation(script:WaitForChild("CrawlAnim"))
local plr = game:GetService("Players").LocalPlayer
local gui = plr.PlayerGui:WaitForChild("GameGui")
local isCrawling = plr:WaitForChild("Crawling")
local isRunning = plr:WaitForChild("Running")
local VrService = game:GetService("VRService")
local isVr = VrService.VREnabled
local RunService = game:GetService("RunService")
hum.Running:Connect(function(speed)
if speed > 0 then
crawlAnim:AdjustSpeed(1)
else
crawlAnim:AdjustSpeed(0)
end
end)
while true do
if plr.CameraMode == Enum.CameraMode.Classic then
hum.CameraOffset = Vector3.new(0,0,0)
end
wait(1)
end
UIS.InputBegan:Connect(function(input, processed)
print("working")
if input.KeyCode == Enum.KeyCode.LeftControl and not processed then
if not isCrawling.Value and not isRunning.Value then
if not (plr.CameraMode == Enum.CameraMode.Classic) then
hum.CameraOffset = Vector3.new(0, -4, -2.5)
end
print("Crawl")
isCrawling.Value = true
crawlAnim:Play()
crawlAnim:AdjustSpeed(0)
crawlAnim.TimePosition = 0.683
hum.WalkSpeed = hum.WalkSpeed / 2
elseif isCrawling.Value and not isRunning.Value then
if not (plr.CameraMode == Enum.CameraMode.Classic) then
hum.CameraOffset = Vector3.new(0, 0, -0.6)
end
print("No Crawl")
isCrawling.Value = false
crawlAnim:Stop()
hum.WalkSpeed = hum.WalkSpeed * 2
end
end
end)
gui:WaitForChild("CrawlButton").Activated:Connect(function()
if not isCrawling.Value and not isRunning.Value then
if not (plr.CameraMode == Enum.CameraMode.Classic) then
hum.CameraOffset = Vector3.new(0, -4, -2.5)
end
isCrawling.Value = true
crawlAnim:Play()
crawlAnim:AdjustSpeed(0)
crawlAnim.TimePosition = 0.683
hum.WalkSpeed = hum.WalkSpeed / 2
elseif isCrawling.Value and not isRunning.Value then
if not (plr.CameraMode == Enum.CameraMode.Classic) then
hum.CameraOffset = Vector3.new(0, 0, -0.6)
end
isCrawling.Value = false
crawlAnim:Stop()
hum.WalkSpeed = hum.WalkSpeed * 2
end
end)