Help with adjusting moving part

So I have this Ice Trident that goes to the position of the players mouse, but I want it to be facing this direction and is facing the direction it is going:

I have tried orientations and that didnt seem to work, and I dont have any other idea how to implement this. Thanks for the help!

Video of whats happening:
robloxapp-20221009-1610299.wmv (872.6 KB)

Script:

game.ReplicatedStorage.Remotes.IceShard.OnServerEvent:Connect(function(player, mousep)
	local tweenservice = game:GetService('TweenService')
	local clone = game.ReplicatedStorage.Fruits.Ice.Shard:Clone()
	local char = player.Character
	clone.CFrame = char.LowerTorso.CFrame 
	clone.Position = Vector3.new(clone.Position.X, clone.Position.Y, clone.Position.Z)
		clone.Parent = char

	local tweeninfo = TweenInfo.new(
		0.6,	
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)
	local tween = tweenservice:Create(clone, tweeninfo, {Position = mousep.Position})
		tween:Play()
		player.stats.Stamina.Value = player.stats.Stamina.Value - 10
		

		tween.Completed:Wait()
	local hitboxclone = game.ReplicatedStorage.HitBox:Clone()
	hitboxclone.Parent = clone
	hitboxclone.Position =  clone.Position
	local explosion = Instance.new('Explosion')
	explosion.Parent = clone
	explosion.BlastRadius = '10'
	local smoke = game.ReplicatedStorage.Ice:Clone()
		smoke.Parent = clone
		clone:Destroy()
		print('destroyed')

	
end)

Dont worry, I’m planning to change it to BodyVelocities in the future!

add this before playing the tween:

clone.CFrame = CFrame.lookAt(clone.Position, mousep.Position)

I just added it, there was no difference

I believe this has to do with the way the trident is oriented. Could you provide the trident model so I could try and fix this in my studio? It’s a bit hard to try and mess with weird orientations without it being hands-on.

Alright, also is these a way you can make 2 meshes into 1 part or they attach together. Ive tried with weld constraints and only the bottom part of the trident part cloned. Sorry for the late response.

Model: Ice Trident - Roblox

game.ReplicatedStorage.Remotes.IceShard.OnServerEvent:Connect(function(player, mousep)
	local tweenservice = game:GetService('TweenService')
	local clone = game.ReplicatedStorage.Fruits.Ice.Shard:Clone() 
	local char = player.Character
	clone.CFrame = char.LowerTorso.CFrame 
         -- add this
	clone.CFrame = clone.CFrame*CFrame.Angles(0 , math.rad(-90) , math.rad(90))
	clone.Parent = char

	local tweeninfo = TweenInfo.new(
		0.6,	
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.Out,
		0,
		false,
		0
	)
	local tween = tweenservice:Create(clone, tweeninfo, {Position = mousep.Position})
	tween:Play()
	player.stats.Stamina.Value = player.stats.Stamina.Value - 10


	tween.Completed:Wait()
	local hitboxclone = game.ReplicatedStorage.HitBox:Clone()
	hitboxclone.Parent = clone
	hitboxclone.Position =  clone.Position
	local explosion = Instance.new('Explosion')
	explosion.Parent = clone
	explosion.BlastRadius = '10'
	local smoke = game.ReplicatedStorage.Ice:Clone()
	smoke.Parent = clone
	clone:Destroy()
	print('destroyed')


end)

Try to use this it my be work for you
i just fix some math issue but still my by not 100% sure if it work or not

Yes, it is very close, it is the trident is tilted a little bit.

Video:
robloxapp-20221009-2018509.wmv (755.4 KB)

1 Like

Here’s the fix I found:

clone.CFrame = CFrame.lookAt(clone.Position, mousep.Position)*CFrame.Angles(math.rad(-90),0,0)

Sorry for the late response, I wasn’t online at the time

Thank you so much! It works perfectly, thanks for your help!

also is these a way you can make 2 meshes into 1 part or they attach together. I’ve tried with weld constraints and only the bottom part of the trident part cloned.

As you can see, the spiky part is not there:
image

The spikey part falls off once it spawns, is there a way to fix this so it looks like this?

Hold on, I will try and find a solution to this.

Alright, I kept them into the model and had both of them anchored. (They were not under each other) I then used this script:

workspace.Trident.PrimaryPart.CFrame = CFrame.lookAt(workspace.Trident.PrimaryPart.Position, workspace.Parta.Position)*CFrame.Angles(80,0,0)
local tween1 = game:GetService("TweenService"):Create(workspace.Trident["Meshes/trident_Plane (1)"], TweenInfo.new(1), {Position = workspace.Parta.Position})
local tween2 = game:GetService("TweenService"):Create(workspace.Trident["Meshes/trident_Cone (1)"], TweenInfo.new(1), {
	Position = workspace.Parta.Position * ((workspace.Trident["Meshes/trident_Plane (1)"].Position - workspace.Parta.Position).Unit * (workspace.Trident["Meshes/trident_Plane (1)"].Position - workspace.Trident["Meshes/trident_Cone (1)"].Position).Magnitude)
})

tween1:Play()
tween2:Play()

The PrimaryPart of the model was set to the trident_Plane. Hopefully you can convert this script to work for you :slight_smile:
Edit: not sure why, but I had to change the angle at which I was using CFrame.Angles() to fix it with the model.

Thank you! It worked again, I also changed it to BodyVelocity to make it the same speed! Thanks for the help!