How would I make this harpoon dart look like it was shot from my direction?

So I made a harpoon gun and I wanted to try to make it look like it came from the player.

Example of what’s happening:
Screenshot 2025-01-11 001841

Code:

local PlayerClicked = game.ReplicatedStorage.PlayerClicked
PlayerClicked.OnServerEvent:Connect(function(Player, PMH)
	local RayOrigin = Player.Character.HumanoidRootPart.Position
	local rayDirection = (PMH - RayOrigin).Unit * 500
	local raycastResult = workspace:Raycast(RayOrigin, rayDirection)
	if raycastResult.Material.Name == "Concrete" then
		local Harpoon = Instance.new("Part")
		Harpoon.Position = raycastResult.Position
		Harpoon.BrickColor = BrickColor.new("Smoky grey")
		Harpoon.Size = Vector3.new(4,0.2,0.2)
		Harpoon.Anchored = true
		Harpoon.Parent = game.Workspace
		Harpoon.Shape = "Cylinder"
	else
		print("CLANG")
	end
end)

You can would change the lookAt property in the Harpoons CFrame

local Harpoon = Instance.new(Part)
Harpoon.Position = raycastResult.Position
Harpoon.BrickColor = BrickColor.new(Smoky grey)
Harpoon.Size = Vector3.new(4,0.2,0.2)
Harpoon.Anchored = true|
Harpoon.Parent = game.Workspace
Harpoon.Shape = "Cylinder"

-- Added Code

local direction = (RayOrigin - Harpoon.Position).unit
Harpoon.CFrame = CFrame.new(Harpoon.Position, Harpoon.Position + direction)

If it’s not rotated on the correct axis you can change it by doing this:

local direction = (RayOrigin - Harpoon.Position).unit

-- Adding a minus on direction.Z will invert that axis
local rotatedDirection = Vector3.new(-direction.Z, direction.Y, direction.X)

Harpoon.CFrame = CFrame.new(Harpoon.Position, Harpoon.Position + rotatedDirection)
1 Like

Works great! but is there some way to make it rotate towards you on the y axis too?

i think making the y axis of the harpoon the same of the player will work :slight_smile: