local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Character = script.Parent
local HMR = script.Parent:WaitForChild("HumanoidRootPart")
local Player = Players:GetPlayerFromCharacter(Character)
local Backpack = Player:WaitForChild("Backpack")
local Tool = Backpack:WaitForChild("Advanced Flashlight")
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local Anim = Animator:LoadAnimation(script:WaitForChild("Animation"))
local ToolAnim = Animator:LoadAnimation(script:WaitForChild("CrawlAnimationTool"))
local isRunning = false
local isEquipped = false
Tool.Equipped:Connect(function()
isEquipped = true
end)
Tool.Unequipped:Connect(function()
isEquipped = false
end)
Humanoid.Running:Connect(function(Speed)
if isEquipped then
if Speed > 0 then
ToolAnim:AdjustSpeed(1)
else
ToolAnim:AdjustSpeed(0)
end
elseif not isEquipped then
if Speed > 0 then
Anim:AdjustSpeed(1)
else
Anim:AdjustSpeed(0)
end
end
end)
function CrawlingTool()
HMR.CanCollide = false
Humanoid.HipHeight = -1.9
Humanoid.CameraOffset = Vector3.new(0, -1, -1.8)
Humanoid.WalkSpeed = 7
Anim:Stop()
ToolAnim:Play()
end
function Crawling()
HMR.CanCollide = false
Humanoid.HipHeight = -1.9
Humanoid.CameraOffset = Vector3.new(0, -1, -1.8)
Humanoid.WalkSpeed = 10
Anim:Play()
ToolAnim:Stop()
Anim:AdjustSpeed(0)
end
function StandingUp()
HMR.CanCollide = true
Humanoid.HipHeight = 0
Humanoid.CameraOffset = Vector3.new(0,0,-0.59)
Humanoid.WalkSpeed = 16
Anim:Stop()
ToolAnim:Stop()
end
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.C then
if not isRunning then
if isEquipped then
isRunning = true
print("CrawlingTool")
CrawlingTool()
elseif not isEquipped then
isRunning = true
print("Crawling")
Crawling()
end
elseif isRunning then
if isEquipped then
isRunning = false
print("RunningTool")
StandingUp()
elseif not isEquipped then
isRunning = false
print("Running")
StandingUp()
end
end
end
end)
Try this, spent some time actually looking at it. I haven’t changed the 3 functions which handle the animations so you may still need to work on those but the rest should work just fine.