Orientation property not changing, how to make a part face another?

Hello. I’ve recently started working on a game, and have made some decent progress in it. However, I’ve run into a problem. Right now I’m programming the script for the attacks, and I’m trying to change the orientation of a part to point to the position of the mouse. Here’s the part:

image

I want it to point in a specific direction.

I’m having trouble with this though, because although the position of the part changes, the orientation doesn’t. Here’s my script:

shard.Parent = game.Workspace
	shard.Position = char.HumanoidRootPart.Position
	shard.Orientation = Vector3.new(CFrame.new(char.HumanoidRootPart.Position, mousepos.Position).lookVector)

mousepos is equivalent to saying plr:GetMouse().Hit.

Am I doing this right?

Also feel free to ask for more of the script.

Maybe you should use CFrame = CFrame.lookAt(part1.position,part2.position)

1 Like

And this sets the position and orientation at the same time?

no it changes only orientation

Weird. Still not working. Here’s my entire script:

local rs = game.ReplicatedStorage
local event = rs.AttackEvents.Hydrogen.HydrogenShardEvent
local ts = game:GetService("TweenService")

local shardSpeed = 36
local damage = 20

event.Event:Connect(function(plr, char, mousepos)
	local shard = rs.AttackResources.HydrogenShard.Parts.HydrogenShard:Clone()
	
	shard.Parent = game.Workspace
	shard.Position = char.HumanoidRootPart.Position
	shard.CFrame = CFrame.lookAt(char.HumanoidRootPart.Position, mousepos.Position)
		
		
	local info = TweenInfo.new(((shard.Position - mousepos.Position).Magnitude / shardSpeed), 
		Enum.EasingStyle.Linear, 
		Enum.EasingDirection.InOut, 0, false, 0)
	local properties = { Position = mousepos.Position }
	local tween = ts:Create(shard, info, properties)
	
	tween:Play()
	
	tween.Completed:Connect(function()
		if shard then
			shard:Destroy()
		end
	end)
	
	local connection
	connection = shard.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			local o_char = hit.Parent
			if o_char.Name ~= plr.Name then
				shard:Destroy()
				if o_char.Humanoid.Health - damage <= 0 then
					connection:Disconnect()
					o_char.Humanoid.Health = 0
					-- tell death script about the death

				else
					connection:Disconnect()
					o_char.Humanoid.Health -= damage

				end
				-- add damage gui

			end
		end
	end)
	
end)
local rs = game.ReplicatedStorage
local event = rs.AttackEvents.Hydrogen.HydrogenShardEvent
local ts = game:GetService("TweenService")

local shardSpeed = 36
local damage = 20

event.Event:Connect(function(plr, char, mousepos)
	local shard = rs.AttackResources.HydrogenShard.Parts.HydrogenShard:Clone()
	
	shard.Parent = game.Workspace
	shard.Position = char.HumanoidRootPart.Position
	shard.CFrame = CFrame.lookAt(shard.Position, mousepos.Position)
		
		
	local info = TweenInfo.new(((shard.Position - mousepos.Position).Magnitude / shardSpeed), 
		Enum.EasingStyle.Linear, 
		Enum.EasingDirection.InOut, 0, false, 0)
	local properties = { Position = mousepos.Position }
	local tween = ts:Create(shard, info, properties)
	
	tween:Play()
	
	tween.Completed:Connect(function()
		if shard then
			shard:Destroy()
		end
	end)
	
	local connection
	connection = shard.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			local o_char = hit.Parent
			if o_char.Name ~= plr.Name then
				shard:Destroy()
				if o_char.Humanoid.Health - damage <= 0 then
					connection:Disconnect()
					o_char.Humanoid.Health = 0
					-- tell death script about the death

				else
					connection:Disconnect()
					o_char.Humanoid.Health -= damage

				end
				-- add damage gui

			end
		end
	end)
	
end)

Nope, this still doesn’t work for some reason.