Hi :), I want that the player can't jump while being crawled but idk how to do it.
local uis = game:GetService("UserInputService") local crawlAnimation = script:WaitForChild("Crawl") local crawlIdle = script:WaitForChild("CrawlIdle") local isCrawling = false local humanoid = script.Parent:WaitForChild("Humanoid") local sprintscript = humanoid.Parent.SprintScript local StarterGui = game:GetService('StarterGui') local loadedIdleAnim = humanoid:LoadAnimation(script:WaitForChild("CrawlIdle")) local loadedCrawlAnim = humanoid:LoadAnimation(script:WaitForChild("Crawl")) local player = game.Players.LocalPlayer local mouse = player:GetMouse() uis.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.C then if isCrawling then isCrawling = false if loadedCrawlAnim then loadedCrawlAnim:Stop() end loadedIdleAnim:Stop() game.ReplicatedStorage.OnCrouchBegun:FireServer(humanoid, 16, 50) sprintscript.Disabled = false humanoid.HipHeight = 0 StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true) elseif not isCrawling then isCrawling = true loadedIdleAnim = humanoid:LoadAnimation(crawlIdle) loadedIdleAnim:Play() game.ReplicatedStorage.OnCrouchBegun:FireServer(humanoid, 8, 0) sprintscript.Disabled = true humanoid.HipHeight = -2 StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false) end end end) game:GetService("RunService").RenderStepped:Connect(function() if not isCrawling then return end if humanoid.MoveDirection.Magnitude > 0 then if not loadedCrawlAnim then loadedCrawlAnim = humanoid:LoadAnimation(crawlAnimation) end if loadedCrawlAnim.IsPlaying == false then loadedCrawlAnim:Play() end else loadedCrawlAnim:Stop() loadedIdleAnim:Play() end end)
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false) disables the ability to jump, changing false to true enables it back:
local uis = game:GetService("UserInputService") local crawlAnimation = script:WaitForChild("Crawl") local crawlIdle = script:WaitForChild("CrawlIdle") local isCrawling = false local humanoid = script.Parent:WaitForChild("Humanoid") local sprintscript = humanoid.Parent.SprintScript local StarterGui = game:GetService('StarterGui') local loadedIdleAnim = humanoid:LoadAnimation(script:WaitForChild("CrawlIdle")) local loadedCrawlAnim = humanoid:LoadAnimation(script:WaitForChild("Crawl")) local player = game.Players.LocalPlayer local mouse = player:GetMouse() uis.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.C then if isCrawling then isCrawling = false if loadedCrawlAnim then loadedCrawlAnim:Stop() end loadedIdleAnim:Stop() game.ReplicatedStorage.OnCrouchBegun:FireServer(humanoid, 16, 50) sprintscript.Disabled = false humanoid.HipHeight = 0 humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true) StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true) elseif not isCrawling then isCrawling = true loadedIdleAnim = humanoid:LoadAnimation(crawlIdle) loadedIdleAnim:Play() game.ReplicatedStorage.OnCrouchBegun:FireServer(humanoid, 8, 0) sprintscript.Disabled = true humanoid.HipHeight = -2 humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false) StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false) end end end) game:GetService("RunService").RenderStepped:Connect(function() if not isCrawling then return end if humanoid.MoveDirection.Magnitude > 0 then if not loadedCrawlAnim then loadedCrawlAnim = humanoid:LoadAnimation(crawlAnimation) end if loadedCrawlAnim.IsPlaying == false then loadedCrawlAnim:Play() end else loadedCrawlAnim:Stop() loadedIdleAnim:Play() end end)
i didn't change anything only added lines 33 and 24