Is it possible to call a part and have it flying at your character from specific points in the air?

How do I go about having a part come at you when called? Like thor’s hammer for example. Do I use bodyvelocity, lookvector?

You can use lerp or tween service

1 Like

Or if you want to apply physics, You can use BodyPosition

You can but using physics can do some lags if you will gonna use it a lot

1 Like

Say I used one remote event for the throw, and another remote event for the call back, how do I reference the position/direction of the clone that was thrown in and have it fly back to me from the same direction?

Wait you trying to do it from server? This too can give lags dont do it if you gonna use it a lot, and if you asking about how works lerp this is how: obj.CFrame = obj.CFrame:Lerp(endCFrame,Number 0 is start and 1 its end)

Lol I know how lerping works. if I don’t do it from the server, other people won’t be able to see it.

Yes so you need do event for server and then to all other clients, sounds like it can give more lags then just do it on server but no

Just so you get an idea with what I’m trying to do, this is what i’ve done so far.
local script:

local HammerEvent = script.Parent:WaitForChild("HammerEvent")
local Tool = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character
local OriginalHammer = game.StarterPack["Thor's Hammer"]
local CallbackEvent = script.Parent:WaitForChild("CallbackEvent")



Tool.Equipped:Connect(function(Mouse)		
Mouse.Button1Down:Connect(function()
	local Location = Mouse.Hit.p
	HammerEvent:FireServer(Location)
	end)
	Mouse.Button2Down:Connect(function()
		CallbackEvent:FireServer()
	end)
end)

Server script:

local HammerEvent = script.Parent:WaitForChild("HammerEvent")
local Handle = script.Parent:WaitForChild("Handle")
local ServerStorage = game:GetService("ServerStorage")
local Hammer = ServerStorage:WaitForChild("Hammer")
local RunService = game:GetService("RunService")
local NotEnabledTime = 2
local EnableTime = 0
local Enable = true
local Thrown = false
local CallBackEvent = script.Parent:WaitForChild("CallbackEvent")

local function OnHammerFired(player, Location)
--print(player, Location)	
	if Enable == true then
		if Thrown == false then
			Thrown = true
		end
     Enable = false	
		
	local ray = Ray.new(Handle.CFrame.p, (Location - Handle.CFrame.p).unit * 300)
	local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
	
	local distance = (Handle.CFrame.p - position).magnitude
	
	Handle.Transparency = 1
	
	local CopieHammer = Hammer:Clone()
	CopieHammer.CanCollide = false
	CopieHammer.CFrame = CFrame.new(Handle.CFrame.p, position) * CFrame.Angles(math.rad(-90), 0, 0)
	CopieHammer.Parent = game.Workspace
	
    local bodyvelocity = Instance.new("BodyVelocity")
    bodyvelocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
    bodyvelocity.velocity = CFrame.new(Handle.CFrame.p, Location).lookVector * 100	
	bodyvelocity.Parent = CopieHammer	
		
	spawn(function()	
	CopieHammer.Touched:Connect(function(hit)
	if hit.Parent.Name ~= player.Name then			
	local humanoid = hit.Parent:FindFirstChild("Humanoid")		
	if humanoid then		
		humanoid:TakeDamage(30)	
		CopieHammer:Destroy()		
		wait(2)			
				
	end			
	end			
	end)		
	end)
	wait(3)			
	CopieHammer:Destroy()							
	Enable = true
end
end

local function OnHammerCall(Player)
	local Character = Player.Character
	local HumanRoot = Character:WaitForChild("HumanoidRootPart",15)
	if Thrown == true then
		Thrown = false
		local HammerCopy = workspace:WaitForChild("Hammer")
		local Handle2 = HammerCopy.Handle
		
		
		local bodyvelocity = Instance.new("BodyVelocity")
		bodyvelocity.maxForce = Vector3.new(math.huge, math.huge, math.huge)
		bodyvelocity.velocity = CFrame.new(Handle2.CFrame,HumanRoot.CFrame).lookVector * 100	
		bodyvelocity.Parent = HammerCopy	
		
		wait(3)
		HammerCopy:Destroy()
		
		Handle.Transparency = 0
		Enable = true
	end
end

HammerEvent.OnServerEvent:Connect(OnHammerFired)
CallBackEvent.OnServerEvent:Connect(OnHammerCall)

I’m not sure how to reference the direction of the hammer that was thrown in and have it flying back at me from the same direction. Do I have to fireclient from the first function to the second remoteevent?

Just ask server return end pos and after it ends when player click right mosue do for it goes back because you know position or you can do better, do for server need only move hammer to new pos but this new pos you counts in local and when you click right mouse you just send pos of you character and hammer will fly back

lol it’s kinda hard to understand your reply fam.

Sry for my english. So just count end position on client and send it to server so it will move it and repeat this for moving this back