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.
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.)
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
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!
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)
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