I'm currently working on an attack on titan like grappling system and I'm trying to use ropeconstraints to pull the player around and swing the player. This is my code so far...

local UIS = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local tweenService = game:GetService("TweenService")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded
local hum = char:WaitForChild("Humanoid")
local humRootPart = char:FindFirstChild("HumanoidRootPart")
local mouse = plr:GetMouse()
local cam = workspace.CurrentCamera
local hookPoint = Vector3.new(0, 0, 0)
local isGrappleHookAttached = false
local isOnWall = false
local canAttach = true
local grapplingHookLength = 15000
local isIdle = true

function grappleHookRight()
	UIS.InputBegan:Connect(function(input, gameProcessedEvent)
		if UIS:IsKeyDown(Enum.KeyCode.E) then
			
			local ray = Ray.new(humRootPart.Position, (mouse.Hit.p - humRootPart.Position).unit * 300)
			local hit, position, normal = game.Workspace:FindPartOnRay(ray, char)
			local distance = (position - humRootPart.Position).magnitude
			
			grappleRight = Instance.new("RopeConstraint", game.Workspace)
			at0 = Instance.new("Attachment", humRootPart)
			at0.Position = Vector3.new(0, 0, 0)
			at1 = Instance.new("Attachment", mouse.Target)
			at1.WorldPosition = position
			
			if hit then
				grappleRight.Thickness = 0.05
				grappleRight.Attachment0 = at0
				grappleRight.Attachment1 = at1
				grappleRight.Visible = true
				grappleRight.Enabled = true
				grappleRight.Color = BrickColor.new("Black")
				grappleRight.Length = distance
				
				runService.Heartbeat:Wait()
				local bodyPos = Instance.new("BodyPosition", humRootPart)
				bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
				bodyPos.P = 1500
				bodyPos.Position = position
				
				UIS.InputEnded:Connect(function(input, gameProcessedEvent)
					bodyPos:Destroy()
					grappleRight:Destroy()
					at0:Destroy()
					at1:Destroy()
				end)
			end
		end
	end)
end

grappleHookRight()

I don't have any idea how to make the player swing around. Please help.

3 comments

0

try shortening the length of the rope constraint to make it so the player is pulled closer to it making it swing

0

try shortening the length of the rope constraint to make it so the player is pulled closer to it making it swing

0

how would I go about doing that?