How to "Throw" a Weapon

So my weapons are essentially WeldConstrainted to a part which is Motor6D connected to my Player.

Now I want to be able to throw the weapon at which it moves forwards a certain number of studs (whilst rotating) in a certain direction before then returning to the original position it was in and then of course I would re-enabled the Weld Constraint.

How would I do this?

Any help is appreciated and if you can give an example too please.
Thank you.

2 Likes

So basically you want to make a boomerang? @Synzxs

1 Like

Just shoot it out based on the direction of either your mouse or lookvector of the part/forward direction of character.

Then once it gets to a certain distance/certain amount of time passed, having it go move back to the rootpart or if you want to get complicated, the literal grip of the character (not that complicated, just look for the attachment).

You can decide to handle this all with tweens (benefit is that you dont mess around with physics)
BodyMovers (Legacy but still gets the job done, BodyPosition is very useful)
Attachemnts (Not legacy and has “Align Position” plus you can mess with it more, but requires more finicky things with attachments.)

1 Like

Alright so basically I whipped up this thing and it seems to work actually pretty decently, obviously its not optimized and stuff but it works, heres a video, also at the end I wasnt even sure if the boomerang would make it back but somehow it found my character XD

2 Likes

Yes but with a Lightsaber? Oh dang that looks cool, how’d you do that?

Do you potentially have a coding example of what I should do?

I’m quite new to CFrames and lookVector.

So basically in a playeradded event I weld it to the players hand and position it accordingly and then after that I go to a local script and detect when the MouseButton1 is pressed using userinputservice and then when it is I check if there are any weld constraints inside of the player’s arms and if there are then break them and then move the boomerang a couple studs up so when the animation plays it looks better, then i quickly add a bodyvelocity to it and then after that i run a loop and set the bodyvelocity of it to the inverse of what i originally set it to, so it always comes back to my humanoidrootpart and then i have an if statement, where it checks if the boomerang is less than 7 studs or so away and if it is position it accordingly and then make a new weld!

So essentially what you are suggesting something like this?:

local function Throw()
--Player WeldConstraint.Enabled = false
BV = Instance.new("BodyVelocity")
BV.Parent = Saber
BV.Velocity = Humanoid.PrimaryPart.CFrame.lookVector * 90
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
wait(1)
BV.Velocity = Vector3.new(BV.Position - HumanoidRootPart.Position)
BV:Destroy()
--Player WeldConstraint.Enabled = true
end

I’m very bad at Velocity n CFrames

You got it all good up until the wait, you want to make a loop after that hold on

Here is my final script, this is all done on the client

local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local humrp = char:WaitForChild("HumanoidRootPart")
local uis = game:GetService("UserInputService")

local connection


uis.InputBegan:Connect(function(i,t)
	if t then return end
	if i.UserInputType == Enum.UserInputType.MouseButton1 then
		local animation = script.throw
		hum:LoadAnimation(animation):Play()
		for i,v in pairs(char:WaitForChild("Right Arm"):GetChildren()) do
			if v:IsA("WeldConstraint") then
				v:Destroy()
				print(v.Name.." was destroyed!")
			end
		end
		local bv = Instance.new("BodyVelocity")
		bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
		bv.Velocity = char:WaitForChild("HumanoidRootPart").CFrame.lookVector * 30
		bv.Parent = game.Workspace:WaitForChild("boomerang")
		game.Workspace:WaitForChild("boomerang").Position = game.Workspace:WaitForChild("boomerang").Position + Vector3.new(0,5,0)
		local timepassed = tick()
		connection = game:GetService("RunService").Stepped:Connect(function()
			game.Workspace:WaitForChild("boomerang").CFrame = game.Workspace:WaitForChild("boomerang").CFrame * CFrame.Angles(0,0,3)
			wait(2.5)
			bv.Velocity = humrp.CFrame.lookVector * -100
			if (humrp.Position - game.Workspace:WaitForChild("boomerang").Position).Magnitude < 10 then
				game.Workspace:WaitForChild("boomerang").Position = char:WaitForChild("Right Arm").RightGripAttachment.WorldPosition
				local newweld = Instance.new("WeldConstraint")
				newweld.Parent = char:WaitForChild("Right Arm")
				newweld.Part0 = char:WaitForChild("Right Arm")
				newweld.Part1 = game.Workspace:WaitForChild("boomerang")
				bv:Destroy()
				connection:Disconnect()
			end 
		end)
	end
end)
2 Likes

These are the issues I got
https://gyazo.com/2fda33e4913a36ce9daa22ee5d46ae98

Here’s the setup of the Saber
https://gyazo.com/8457ba8a7c5cb2c4808e8f1bbb7bbe0f
All the Welds are stored under the Primary Part (The Grip)

Here’s the script when I modified it:

local tabler = {}
			local val = Saber.Grip.Position
			tabler["Saber"] = val
			local BV = Instance.new("BodyVelocity")
			Player.Character.R1["RightGrip"].Enabled = false
		
			BV.Parent = Saber.Grip
			BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
			BV.Velocity = Player.Character.HumanoidRootPart.CFrame.lookVector * 30
			Saber.Grip.Position = Saber.Grip.Position + Vector3.new(0,5,0)
			local timepassed = tick()
			local connection = game:GetService("RunService").Stepped:Connect(function()
				Saber.Grip.CFrame = Saber.Grip.CFrame * CFrame.Angles(0,0,3)
				wait(2.5)
				BV.Velocity = Player.Character.HumanoidRootPart.CFrame.lookVector * -100
				if (Player.Character.HumanoidRootPart.Position - Saber.Grip.Position).Magnitude < 10 then
					Saber.Grip.Position = tabler["Saber"]
				end
				BV:Destroy()
			end)
			wait(6)
			connection:Disconnect()
			Player.Character.R1["RightGrip"].Enabled = true

@loveicicIe

Well from the first gif it looks like the lightsaber part and the handle arent moving synchronously, so make sure to move the whole lightsaber model and make sure they are welded

So i need to apply a body velocity to each individual item in the Saber?

Wait send me the model and let me see if I can take a swing at it and then give you the code

Okay, do you have discord?

If so can you contact me at: S Y N#0550
@loveicicIe

You can use a BodyPosition and a BodyForce at the same time, making the bodyforce significantly higher, but then making it fall.