How can I make this part face the same way as the humanoidrootpart?

  1. What do you want to achieve? I want to make the part that spawns face the same way

  2. What is the issue? I made it spawn in front of the char but it’s sideways (it’s a small part with two attachments in it)
    Screen Shot 2021-11-07 at 1.45.18 PM

  3. What solutions have you tried so far? non bc i dont understand CFrame rotations

here’s my code

local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://7927315544"

local RS = game:GetService("ReplicatedStorage")
local waterParticles = RS:FindFirstChild("WaterEffect")

game.Players.PlayerAdded:Connect(function(Player)
	local debounce = false
	Player.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:WaitForChild("Humanoid")
		Player.Chatted:Connect(function(msg)
			local spell = string.lower(msg)
			if spell == "aquam alia" and not debounce then
				local witch = Character:FindFirstChild("Hope")
				if witch.Value == true then
					local magic = Character:FindFirstChild("Magic")
					if magic.Value > 200 then
						print("enough magic")
						debounce = true
						local Anim = Character:WaitForChild("Humanoid"):LoadAnimation(Animation)
						Anim:Play()
						local waterParticles = RS:FindFirstChild("WaterEffect"):Clone()
						
						wait(1)
						
						for _,BodyPart in pairs(Character:GetChildren()) do
							if BodyPart:IsA("Part") or BodyPart:IsA("UnionOperation") or BodyPart:IsA("MeshPart") then
								BodyPart.Anchored = true
							end
						end

						waterParticles.Parent = workspace
						local offset = Vector3.new(0,1,-3)
						waterParticles.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(offset)
						wait(0.5)
						waterParticles.Blast.Blast.Enabled = true
						
						local check = Instance.new("Part")
						check.Shape = Enum.PartType.Block
						local offset = Vector3.new(0,0,-33)
						check.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(offset)
						check.Size = Vector3.new(4, 6.5, 58)
						check.Anchored = true
						check.CanCollide = false
						check.Name = Character.Name.."'s check part"
						check.Transparency = 1
						check.Parent = workspace
						print("made part")

						check.Touched:Connect(function(target)
							if target.Parent:IsA("Model") then -- the part that errors								
								if target.Parent.Name == Character.Name then return end

								local cf = CFrame.lookAt(target.Parent.HumanoidRootPart.Position, Character.HumanoidRootPart.Position)
								target.Parent.HumanoidRootPart.CFrame = cf

								target.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)

								local bv = Instance.new("BodyVelocity")
								bv.Velocity = target.Parent.HumanoidRootPart.CFrame.LookVector * -50
								bv.Parent = target
								wait(0.3)
								bv:Destroy()
								target.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
							end
						end)

						for count = 1,10 do
							wait()
							magic.Value -= 5
						end
						
						wait(5)
						check:Destroy()
						waterParticles:Destroy()
						
						for _,BodyPart in pairs(Character:GetChildren()) do
							if BodyPart:IsA("Part") or BodyPart:IsA("UnionOperation") or BodyPart:IsA("MeshPart") then
								BodyPart.Anchored = false
							end
						end
					end
				end
			end
			wait(5)
			debounce = false
			print("can work now")
		end)
	end)				
end)

all help is appreciated

2 Likes

Part.Orientation = HumanoidRootPart.Orientation - Vector3.new(0, 180, 0)

This should do the trick.

2 Likes

You could also use Part.LookVector = HumanoidRootPart.LookVector.