Hello, i have a Crawl Script and i need help with it, if u equip a tool and then crouch ur walkspeed is 4, if u dont equip A tool then crouch ur walkspeed will be different, how will i make this work if it gets changed Mid crawl?
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 Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local Anim = Animator:LoadAnimation(script:WaitForChild("Animation"))
local IsCrawling = false
local IsHoldingTool = false
function ToolChange()
if script.HoldingTool.Value == false then
IsHoldingTool = false
else
if script.HoldingTool.Value == true then
IsHoldingTool = true
end
end
end
script.HoldingTool.Changed:Connect(ToolChange)
Humanoid.Running:Connect(function(Speed)
if Speed > 0 then
Anim:AdjustSpeed(1)
else
Anim:AdjustSpeed(0)
end
end)
function Crawling()
HMR.CanCollide = false
Humanoid.HipHeight = 0
Humanoid.CameraOffset = Vector3.new(0, -1, -1.8)
Humanoid.WalkSpeed = 10
Anim:Play()
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()
end
function ToolHolding()
HMR.CanCollide = false
Humanoid.HipHeight = 0
Humanoid.CameraOffset = Vector3.new(0, -1, -1.8)
Humanoid.WalkSpeed = 4
Anim:Play()
Anim:AdjustSpeed(0)
end
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.C then
if not IsCrawling and not IsHoldingTool then
Crawling()
IsCrawling = true
else
if not IsCrawling and IsHoldingTool then
IsCrawling = true
ToolHolding()
else
if IsCrawling then
IsCrawling = false
StandingUp()
end
end
end
end
end)