So I have a problem im a star wars developer and my players have been asking me to add saber throw to the lightsabers here's a part of it .. Did I forgot something ?

function ThrowAttack()
	if throwing == true and enabled then
		candamage = true
		local saber = character:findFirstChild(ls)
		local throwingHandle = saber:Clone()
		DebrisService:AddItem(throwingHandle, 5)
		throwingHandle.Parent = game.Workspace
		for _, child in ipairs(throwingHandle:GetChildren("ManualWeld" and "EmitterWeld" and "SaberWeld")) do
		child:remove()
		end
		wait()
		throwingHandle.Handle.Velocity = (mouse.TargetPoint - saber.Handle.CFrame.p).unit * 100
		saber.Handle.SaberWeld.C0 = CFrame.new(saber.Handle.CFrame.p, saber.Handle.CFrame.p + saber.Handle.Velocity) * CFrame.Angles(0, 0, math.rad(-90))
		local floatingForce = Instance.new('BodyForce', saber.Handle)
		floatingForce.force = Vector3.new(0, 196.2 * saber.Handle:GetMass() * 0.98, 0)
		local spin = Instance.new('BodyAngularVelocity', saber.Handle)
		spin.angularvelocity = saber.Handle.CFrame:vectorToWorldSpace(Vector3.new(0, -400, 0))
		
		wait()
		if saber.Handle then
			local touchedConn = saber.Handle.Touched:connect(function(hit)
			saber.Handle.Velocity = (mouse.TargetPoint + saber.Handle.CFrame.p).unit * 100
			saber.Handle.SaberWeld.C0 = CFrame.new(saber.Handle.CFrame.p, saber.Handle.CFrame.p + saber.Handle.Velocity) * CFrame.Angles(0, 0, math.rad(-90))
			local floatingForce = Instance.new('BodyForce', saber.Handle)
			floatingForce.force = Vector3.new(0, 196.2 * saber.Handle:GetMass() * 0.98, 0)
			local spin = Instance.new('BodyAngularVelocity', saber.Handle)
			spin.angularvelocity = saber.Handle.CFrame:vectorToWorldSpace(Vector3.new(0, -400, 0))
			end)
		end
		wait(0.6)
		if saber.Handle and throwing then
			WeldParts(character["Right Arm"])
			saber.Handle.SaberWeld.C0 = CFrame.new(0,-1,0) * CFrame.fromEulerAnglesXYZ(math.rad(90),math.rad(180),math.rad(180))
			saber.Parent = character
			throwing = false
			candamage = false
		end
	end
end

2 comments

1

Oh my. Put it in code block properly please.

0

Do you get any errors?