How to Make a CROUCH SYSTEM in Roblox Studio

Поделиться
HTML-код
  • Опубликовано: 9 фев 2025

Комментарии • 117

  • @FalseMind
    @FalseMind 6 месяцев назад +56

    Full LocalScript
    local UIS = game:GetService("UserInputService")
    local Crouching = false
    local Character = script.Parent
    local Humanoid = Character:WaitForChild("Humanoid")
    local Animation = script.CrouchAnimation
    UIS.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.C then
    if Crouching == false then
    Crouching = true
    LoadedAnimation = Humanoid:LoadAnimation(Animation)
    LoadedAnimation:Play()

    Humanoid.HipHeight -= 1.2
    Humanoid.WalkSpeed = 8
    Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
    else
    Crouching = false
    LoadedAnimation:Stop()

    Humanoid.HipHeight += 1.2
    Humanoid.WalkSpeed = 16
    Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
    end
    end
    end)

  • @piexk_Evie
    @piexk_Evie 4 месяца назад +20

    finally a tutoriall that isnt "USE MY FREE MODEL!!!"

  • @Teaflake
    @Teaflake 5 месяцев назад +7

    THANK YOU soooo much ive checked every video and not one worked but this one did thank you

  • @deathtree0
    @deathtree0 28 дней назад +2

    THANK YOU SOOOOOOO MUCH BRO THIS IS SO USEFUL, IVE BEEN TRYING TO MAKE A HORROR GAME FOR MONTHS! (almost become a year)

  • @deathdoesroblox
    @deathdoesroblox 7 месяцев назад +4

    Great video man, it was such a great video, from the very beginning

    • @devmelonroblox
      @devmelonroblox  7 месяцев назад +2

      Thank you very much dear sire death who greatly does Roblox

    • @TedMeister_w
      @TedMeister_w 4 месяца назад +4

      YO HI DEATH I RANDOMLY SAW U IN AN MM2 SERVER NOW ON A COMMENT ON A RANDOM VIDEO LOL

    • @deathdoesroblox
      @deathdoesroblox 4 месяца назад

      @@TedMeister_w what a coincidence 😂😂 a pleasure to meet you too 🔥🔥

    • @devmelonroblox
      @devmelonroblox  4 месяца назад

      @@TedMeister_w yeeeee

  • @haterquenaodahate6334
    @haterquenaodahate6334 7 месяцев назад +3

    Your videos are the best I found to start programming , keep it up man

    • @devmelonroblox
      @devmelonroblox  7 месяцев назад +1

      Thanks ❤

    • @SussyAmogus2203
      @SussyAmogus2203 7 месяцев назад +2

      @@devmelonroblox but tysm i appreciate it the script is usefull

  • @Spa.wnPoint
    @Spa.wnPoint 6 месяцев назад +1

    W vid
    Man ive been using your tutorials and they
    Never upset anyone keep the good work! ^_^

  • @FlowByteStudios
    @FlowByteStudios 5 месяцев назад +1

    Amazing video thank you so much you deserve more views +1 sub

  • @pamniedzielski6100
    @pamniedzielski6100 2 месяца назад

    Yoooo! Thank you so much this helped me a lot!

  • @BbenniWoerm
    @BbenniWoerm Месяц назад +5

    is there a way to make it where if u stop moving the anim stops but if u walk/crouch it will do that if ya know what i mean?

  • @SussyAmogus2203
    @SussyAmogus2203 7 месяцев назад +7

    here is the script :
    local UIS = game:GetService("UserInputService")
    local UIS = game:GetService("UserInputService")
    local crouching = false
    local character = script.Parent
    local humanoid = character:WaitForChild("humanoid")
    local animation = script.crouchanimation
    UIS.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.C then
    if crouching == false then
    crouching = true
    loadedanimation = humanoid:loadedanimation(animation)
    loadedanimation:play()

    humanoid.hipHeight -= 1.2
    humanoid.walkspeed = 8
    humanoid:setStateEnabled(Enum.HumanoidStateType,jumping, false)
    else
    crouching = false
    loadedanimation:stop()
    humanoid.hipHeight += 1.2
    humanoid.walkspeed = 16
    humanoid:setStateEnabled(Enum.HumanoidStateType,jumping, true)
    end
    end
    end)

  • @iamKizo_
    @iamKizo_ 12 дней назад

    Guys just remember if u code the animation with a R6 character u gotta change the gamesettings to R6 otherwise the animation wont play

  • @MSM-OSOW
    @MSM-OSOW Месяц назад

    for those who don't want to use "crouch = false", but rather invert the value, just put "crouch = not crouch" after the loop on line 13

  • @esraanada2936
    @esraanada2936 6 месяцев назад +5

    There is something going wrong for me, it also happened when i did the sliding animation from one of your videos too, whenever i press the button, nothing happens
    .

    • @senphoenix9507
      @senphoenix9507 5 месяцев назад

      Same

    • @LeBaconator-j3f
      @LeBaconator-j3f 4 месяца назад

      same

    • @aeea3306
      @aeea3306 3 месяца назад

      You sure you didn't just misspell some parts? Cuz that's usually what happens when these kinds of problems happen, or maybe you used the wrong type of script or put it in the wrong place

    • @ziiiiink
      @ziiiiink 2 месяца назад

      Part of the issue could be because :loadAnimation() has been deprecated. It still works, but it's unreliable.

  • @shadowing_studio
    @shadowing_studio 7 месяцев назад +3

    im here ;3

  • @henriquebigolin2006
    @henriquebigolin2006 7 месяцев назад +4

    Very Simple brooo very good

  • @Fiasdo_short
    @Fiasdo_short 2 месяца назад +1

    Were do you do the whole thing Like witch Button is it or Plug in?

  • @JMFlores-r2u
    @JMFlores-r2u Месяц назад

    man bro this guy is a legend

  • @PumpkinMan13-h8u
    @PumpkinMan13-h8u 2 месяца назад +1

    Can you make a tutorial sequal to this video making it where when the player moves (while crouching) it plays a walking (crouch) animation? PLEASE I WANT MY GAME TO BE GOOD😭

  • @shadowing_studio
    @shadowing_studio 7 месяцев назад +3

    W vid fr

  • @OfficiallyHaha
    @OfficiallyHaha Месяц назад

    i can crouch but when i walk while crouching its not looking good how do u fix it but without the walking problem this is the best one i found thx bro

  • @OfficialIsaac_playzRBX
    @OfficialIsaac_playzRBX 19 дней назад +1

    Could you copy the script?

  • @chellodevZ
    @chellodevZ 7 месяцев назад +2

    Second
    Also W

  • @LiamFurgason
    @LiamFurgason 6 месяцев назад +2

    What about a crouching walking animation?

    • @devmelonroblox
      @devmelonroblox  6 месяцев назад +1

      @@LiamFurgason I might make a part 2

  • @FludPlayz
    @FludPlayz 17 дней назад

    Does it still work because my animation is not working but the crouch is.

  • @Varxiii
    @Varxiii 6 дней назад

    my character's entire lower half warps into the floor no matter the value i type in for hip height, anyone know how to fix?

  • @AntiMyanmarGovernmentOperative
    @AntiMyanmarGovernmentOperative 7 месяцев назад +2

    LETS GOOOO W UPLOAD SCHEDULE

  • @tylerkasturi1209
    @tylerkasturi1209 4 месяца назад

    great video! one question though;
    when a player is crouching under something, if they uncrouch while still under it then they'll stand up inside of it and get stuck, unless they crouch again. how could you modify the code to make it so that when a player is underneath something, they're unable to press the button until they have adequate room above them to do so?
    thanks!

  • @thefilipinoman21423
    @thefilipinoman21423 5 месяцев назад +1

    hey can you help? whenever i uncrouch it wont stop crouching, the hipheight would return to normal but the animation wont stop

    • @thefilipinoman21423
      @thefilipinoman21423 5 месяцев назад +1

      nevermind i fixed it :P

    • @notnooby2118
      @notnooby2118 4 месяца назад +1

      @@thefilipinoman21423 yo i have that same issue how did u fix it?

    • @thefilipinoman21423
      @thefilipinoman21423 4 месяца назад +1

      @@notnooby2118 copy the actual script lol, dont correct any orange lines

    • @notnooby2118
      @notnooby2118 4 месяца назад +1

      @@thefilipinoman21423 thanks

  • @fatmaozen9395
    @fatmaozen9395 28 дней назад

    the animation doesnt play for me

  • @AbduIz
    @AbduIz Месяц назад

    but can you make walk crouch animation script

  • @AbduIz
    @AbduIz Месяц назад

    it doesn't work at all at ViewModel

  • @EpixKerek
    @EpixKerek Месяц назад

    could someone please help me? it wont work.

  • @1_NOTTHING
    @1_NOTTHING 4 месяца назад

    can you pls make a running system?

  • @Goat_Gaming-147
    @Goat_Gaming-147 Месяц назад

    it wont play the animation for me

  • @Kaiser_Edits.NoLeimporta
    @Kaiser_Edits.NoLeimporta 2 месяца назад

    idk why it doesn't slowes me

  • @mekooGuide
    @mekooGuide 16 дней назад

    it dosent play the animation

  • @henrynguyen-t4b
    @henrynguyen-t4b Месяц назад

    is this r15 or r6?

  • @Prixymrf
    @Prixymrf 8 дней назад

    the animation does not work in the startercharacterscript cant add>:(

    • @Prixymrf
      @Prixymrf 8 дней назад

      AND I STILL CAN RUN WITH SHIFT

  • @gamefeatures8509
    @gamefeatures8509 5 месяцев назад +1

    its not working for me bruh

  • @Mrexplosives333
    @Mrexplosives333 5 месяцев назад +1

    Hey devmelon pls help it didt work for me

  • @droxam
    @droxam 4 месяца назад

    im levitating bro idk what is happening

  • @tondamelkus1011
    @tondamelkus1011 2 месяца назад

    it doesnt work for me

  • @pamniedzielski6100
    @pamniedzielski6100 2 месяца назад

    I'm on my parents account btw

  • @Mr_marcvin
    @Mr_marcvin Месяц назад

    why i cant :(

  • @notnooby2118
    @notnooby2118 4 месяца назад +2

    I can't get my code to work
    local UIS = game:GetService("UserInputService")
    local Crouching = false
    local Character = script.Parent
    local Humanoid = Character:WaitForChild("Humanoid")
    local Animation = script.CrouchAnimation
    UIS.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.C then
    if Crouching == false then
    Crouching = true
    LoadedAnimation = Humanoid:LoadAnimation(Animation)
    LoadedAnimation:Play()

    Humanoid.HipHeight -= 1.2
    Humanoid.WalkSpeed = 7
    Humanoid:SetStateEnable(Enum.HumanoidStateType.Jumping, false)
    else
    Crouching = false
    LoadedAnimation = Humanoid:LoadAnimation(Animation)
    LoadedAnimation:Stop()
    Humanoid.HipHeight += 1.2
    Humanoid.WalkSpeed = 16
    Humanoid:SetStateEnable(Enum.HumanoidStateType.Jumping, true)
    end
    end
    end)

    • @Menezia
      @Menezia 24 дня назад

      try this
      local UIS = game:GetService("UserInputService")
      local Crouching = false
      local Character = script.Parent
      local Humanoid= Character:WaitForChild("Humanoid")
      local Animation = script.CrouchAnimation
      UIS.InputBegan:Connect(function(key)
      if key.KeyCode == Enum.KeyCode.C then
      if Crouching == false then
      Crouching = true
      LoadedAnimation = Humanoid:LoadAnimation(Animation)
      LoadedAnimation:Play()
      Humanoid.HipHeight -= 1.5
      Humanoid.WalkSpeed = 10
      Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
      else
      Crouching = false
      LoadedAnimation:Stop()
      Humanoid.HipHeight+=1.5
      Humanoid.WalkSpeed = 23
      Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
      end
      end
      end)

  • @er_aviation
    @er_aviation 7 месяцев назад

    Mobile support?

    • @devmelonroblox
      @devmelonroblox  6 месяцев назад +1

      I will make mobile buttons tut soon!

  • @XDxbox420
    @XDxbox420 7 месяцев назад +2

    DevMelon shake🥴🥴🥴

  • @That_crab_guy
    @That_crab_guy 4 месяца назад

    It does not work

  • @castlecrasher2012
    @castlecrasher2012 4 месяца назад

    not working

  • @senphoenix9507
    @senphoenix9507 5 месяцев назад

    Didn’t work

  • @simuliukas893
    @simuliukas893 Месяц назад

    it doesn't work😡

  • @speedy_monkey
    @speedy_monkey 3 месяца назад

    broooo thats not working

    • @Munchie-m5p
      @Munchie-m5p 2 месяца назад

      Here's a better script, when you crouch and your under something for example, your under a table, it stays in crouch for realism.
      Just make sure to put it in StarterPlayerScripts as a local script
      Here:
      -- Server Script (in ServerScriptService)
      local replicatedStorage = game:GetService("ReplicatedStorage")
      local crouchEvent = replicatedStorage:WaitForChild("CrouchEvent")
      local crouchHeight = 0.2 -- Adjust this for crouch depth
      local headClearance = 3 -- Adjust this for head clearance when standing up
      -- Function to check if there's space to stand up
      local function canStand(character)
      local headPosition = character.Head.Position
      local rayDirection = Vector3.new(0, headClearance, 0)
      local raycastParams = RaycastParams.new()
      raycastParams.FilterDescendantsInstances = {character}
      raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
      local raycastResult = workspace:Raycast(headPosition, rayDirection, raycastParams)
      return raycastResult == nil -- If no obstacle above, it’s safe to stand
      end
      -- Handle crouch requests from client
      crouchEvent.OnServerEvent:Connect(function(player, isCrouching)
      local character = player.Character
      if character then
      local humanoid = character:FindFirstChild("Humanoid")
      if humanoid then
      -- Store the original HipHeight if it's not already stored
      if not humanoid:GetAttribute("OriginalHipHeight") then
      humanoid:SetAttribute("OriginalHipHeight", humanoid.HipHeight)
      end
      local originalHipHeight = humanoid:GetAttribute("OriginalHipHeight")
      if isCrouching then
      -- Set HipHeight to crouch height
      humanoid.HipHeight = crouchHeight
      else
      -- Only stand up if there’s space above the character
      if canStand(character) then
      humanoid.HipHeight = originalHipHeight
      end
      end
      end
      end
      end)

  • @WalkingTaco187
    @WalkingTaco187 7 месяцев назад +1

    Ay

  • @zmigal
    @zmigal 7 месяцев назад +1

    Firist😂

  • @trebogolfshopsaikgolfklubb5473
    @trebogolfshopsaikgolfklubb5473 6 месяцев назад

    It didnt work😢

    • @Faizal-rv9mu
      @Faizal-rv9mu 6 месяцев назад

      Turn the action to movement

    • @Mrexplosives333
      @Mrexplosives333 5 месяцев назад

      @@Faizal-rv9mu hey how do i do that

  • @pamniedzielski6100
    @pamniedzielski6100 2 месяца назад

    Can you add me?

  • @SpiritIsOnTop
    @SpiritIsOnTop 5 месяцев назад

    DIDNT EVEN WORK

  • @VolumetricsStudio
    @VolumetricsStudio 5 месяцев назад

    The animation wont play?