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)
This little thing alone may make your channel blow up ;) Keep doing tutorials!
absolute cinema
Ty bro
JUST WHAT I NEEDED ILYSM DUDEEE, have you got a discord?
FINNALY HE MAKE A TUTORIAL
Keep making tutorials your channel might suddenly pop off. Anyways you working on any personal projects?
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.
@@MCSwat12 having trouble connecting the rig attachment to the part attachment, how do i do it?
@
local rope = instance.new("RopeConstraint")
rope.Parent = whatever you want
rope.Attachment0 = one of the attachments
rope.Attachment1 = the other attachment
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
I’ll look into it
use pastebin to put the code then put pastebin code in comments or description
I can't post any links unfortunately, so I just pasted the code in the description best I could
the rope and part dont disappear when i release left mouse button
Are you using the code from the description?
Check if you have 2 remote events, one for hooking one for unhooking
my rig doesent swing like yours and when i play i cant grapple?
where do you have the scripts set up?
@@MCSwat12 startercaracterscripts
You should reread the description, you need 2 different scripts and remote events
let me know if you need anymore help
@@MCSwat12 yep thanks