How do i make my grapple system have swinging?

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local PlayGui = Player.PlayerGui

local Humanoid = Character:FindFirstChild("Humanoid")
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")

local Animator = Humanoid:FindFirstChild("Animator")

local Mouse = Player:GetMouse()

local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()


local MaxGrappleDistance = 100
local GrappleCooldown = 0.5
local GrappleDamage = 10
local GrappleActive = false
local GrappleDebounce = false
local DisableGrappleWhenTouched = false

Humanoid.StateChanged:Connect(function(Old,New)

	Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
	Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)

end)

Mouse.Button1Up:Connect(function()
	GrappleActive = false
end)


Mouse.Button1Down:Connect(function()
	local HitPosition = Mouse.Hit.Position
	local Origin = HumanoidRootPart.Position
	
	local Distance = (HitPosition - Origin).Magnitude
	Distance = math.floor(Distance / 1 + 0.5) * 1
	
	if Distance <= MaxGrappleDistance then
		GrappleActive = true
		local Part = Instance.new("Part")
		Part.Parent = workspace
		Part.Anchored = true
		Part.CanCollide = false
		Part.Transparency = 0.5
		Part.Position = HitPosition
		
		
		local Attachment0 = Instance.new("Attachment")
		Attachment0.Parent = Part
		Attachment0.Name = "GrappleAttachment"
		local Attachment1 = Instance.new("Attachment")
		Attachment1.Parent = HumanoidRootPart
		Attachment1.Name = "GrappleAttachment"
		
		local RopeConstraint = Instance.new("RopeConstraint")
		RopeConstraint.Parent = HumanoidRootPart
		RopeConstraint.Attachment0 = Attachment0
		RopeConstraint.Attachment1 = Attachment1
		RopeConstraint.Length = Distance
		RopeConstraint.Restitution = 0
		RopeConstraint.Visible = true
		RopeConstraint.Color = BrickColor.new("Black")
		
		Humanoid.Touched:Connect(function(Hit)
			if GrappleActive == true and DisableGrappleWhenTouched == true then
				GrappleActive = false
			end
		end)
		
		while GrappleActive == true do
			task.wait(0.1)
		end
		
		local BV = Instance.new("BodyVelocity",HumanoidRootPart)
		BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
		local Direction = (HitPosition - Origin).Unit -- Normalized direction vector
		local LaunchSpeed = HumanoidRootPart.Velocity.Magnitude * 1.5
		if LaunchSpeed < 50 then
			LaunchSpeed = 50
		end
		if LaunchSpeed > 200 then
			LaunchSpeed = 200
		end
		BV.Velocity = Direction * LaunchSpeed
		
		game.Debris:AddItem(RopeConstraint,0.3)
		game.Debris:AddItem(BV,0.3)
		game.Debris:AddItem(Part,0.1)
	end
end)

end)

i dont want to change the players physics to physics because that messes with the camera and causes the player to ragdoll

1 Like

you could use AssemblyLinearVelocity to apply velocity in the direction the camera is facing or even get the move direction of the humanoid to apply the velocity(this may not show correctly while using rope constraint…)

AssemblyLinearVelocity

MoveDirection

also you might could use linearvelocity or vectorforce

2 Likes

yeah i think that should work ill just change the rope constraint to a beam and make the movement with the velocities thank you

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.