How to make a swing grappling hook in Roblox Studio

Поділитися
Вставка
  • Опубліковано 7 лют 2025
  • Quick video explaining how my free, uncopylocked physics based grappling system, from my custom movement and grappling demo works.
    It's going to take a bit before I can post links, so unfortunately this is the best I can provide for you guys at the moment.
    You need 2 remote events in replicated storage, hookEvent and unhookEvent
    Then you put a Script in the serverscriptstorage:
    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local hookEvent = ReplicatedStorage:FindFirstChild("hookEvent")
    local unHookEvent = ReplicatedStorage:FindFirstChild("unHookEvent")
    local grapples = {}
    hookEvent.OnServerEvent:Connect(function(player, mousePosition, torso, distance)
    local hookPart = Instance.new("Part")
    hookPart.Anchored = true
    hookPart.Position = mousePosition
    hookPart.Parent = workspace
    local att0 = Instance.new("Attachment")
    local att1 = Instance.new("Attachment")
    att0.Parent = hookPart
    att1.Parent = torso
    local rope = Instance.new("RopeConstraint")
    rope.Visible = true
    rope.Length = distance
    rope.Attachment0 = att0
    rope.Attachment1 = att1
    rope.Parent = hookPart
    grapples[player.UserId] = {
    HookPart = hookPart,
    Attachment0 = att0,
    Attachment1 = att1,
    Rope = rope
    }
    end)
    unHookEvent.OnServerEvent:Connect(function(player)
    local data = grapples[player.UserId]
    if data then
    data.HookPart:Destroy()
    data.Rope:Destroy()
    data.Attachment1:Destroy()
    grapples[player.UserId] = nil
    end
    end)
    A local script in startercharacterscripts:
    local players = game:GetService("Players")
    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local character = script.Parent
    local torso = character:WaitForChild("HumanoidRootPart")
    local player = players:GetPlayerFromCharacter(character)
    local mouse = player:GetMouse()
    local humanoid = character:WaitForChild("Humanoid")
    local hookEvent = ReplicatedStorage:FindFirstChild("hookEvent")
    local unHookEvent = ReplicatedStorage:FindFirstChild("unHookEvent")
    mouse.Button1Down:Connect(function()
    local mousePosition = mouse.Hit.Position
    local distance = (mousePosition - torso.Position).magnitude
    humanoid:ChangeState(Enum.HumanoidStateType.Physics)
    hookEvent:FireServer(mousePosition, torso, distance)
    end)
    mouse.Button1Up:Connect(function()
    humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
    unHookEvent:FireServer()
    end)

КОМЕНТАРІ • 24

  • @kiba1704
    @kiba1704 5 днів тому +3

    This little thing alone may make your channel blow up ;) Keep doing tutorials!

  • @m7sallat
    @m7sallat 15 днів тому +2

    absolute cinema

  • @Flakethe_1
    @Flakethe_1 22 години тому +1

    Ty bro

  • @ajrryt
    @ajrryt 7 днів тому +1

    JUST WHAT I NEEDED ILYSM DUDEEE, have you got a discord?

  • @PELEMEN_FLOPPEN
    @PELEMEN_FLOPPEN 16 днів тому +1

    FINNALY HE MAKE A TUTORIAL

  • @MrZinvixYT
    @MrZinvixYT 6 днів тому +2

    Keep making tutorials your channel might suddenly pop off. Anyways you working on any personal projects?

    • @MCSwat12
      @MCSwat12  6 днів тому

      I don't know if doing tutorials is my passion but it sure does drive a lot of engagement.
      Yeah I work on little projects here and there, but I'm actually a pretty mediocre dev. I got lucky with my little Humanoid:ChangeState() trick that made this grappling hook special and desireable.

    • @MrZinvixYT
      @MrZinvixYT 6 днів тому

      @@MCSwat12 having trouble connecting the rig attachment to the part attachment, how do i do it?

    • @MCSwat12
      @MCSwat12  4 дні тому

      ​@
      local rope = instance.new("RopeConstraint")
      rope.Parent = whatever you want
      rope.Attachment0 = one of the attachments
      rope.Attachment1 = the other attachment

  • @GameDevbyMuhammad
    @GameDevbyMuhammad 14 днів тому +2

    the tutorial is out but i already find out how did you do the pandulum last month :( but still thank you for the tutorial. but can you make tutorial how to make the player can control when they swing to

    • @MCSwat12
      @MCSwat12  14 днів тому

      I’ll look into it

  • @YoIzec
    @YoIzec 16 днів тому +1

    use pastebin to put the code then put pastebin code in comments or description

    • @MCSwat12
      @MCSwat12  15 днів тому

      I can't post any links unfortunately, so I just pasted the code in the description best I could

  • @crayonrando
    @crayonrando 4 дні тому

    the rope and part dont disappear when i release left mouse button

    • @MCSwat12
      @MCSwat12  4 дні тому

      Are you using the code from the description?
      Check if you have 2 remote events, one for hooking one for unhooking

  • @abntonabnton
    @abntonabnton 13 днів тому

    my rig doesent swing like yours and when i play i cant grapple?

    • @MCSwat12
      @MCSwat12  13 днів тому

      where do you have the scripts set up?

    • @abntonabnton
      @abntonabnton 12 днів тому

      @@MCSwat12 startercaracterscripts

    • @MCSwat12
      @MCSwat12  12 днів тому

      You should reread the description, you need 2 different scripts and remote events

    • @MCSwat12
      @MCSwat12  9 днів тому

      let me know if you need anymore help

    • @abntonabnton
      @abntonabnton 9 днів тому

      @@MCSwat12 yep thanks