How to change orientation on lookvector

so i have this script and i was wondering how to make the new aura orienatation for the players heads lookvector

if aura.Value == "Clock" then
			local auratoclone = game.ReplicatedStorage:WaitForChild("Auras").ClockAura

			local newaura = auratoclone:Clone()
			newaura.Parent = rootpart
			newaura.Position = rootpart.Position
			newaura.Name = "CurrentAura"
			
			local weldconstraint = Instance.new("WeldConstraint")
			weldconstraint.Parent = newaura
			weldconstraint.Part0 = newaura
			weldconstraint.Part1 = rootpart
		end
2 Likes

the code spaces are scuffed up here but in the real code its normal

To orient the ClockAura to follow the player’s head’s LookVector, you need to update the orientation of the aura based on the player’s head direction. Instead of using WeldConstraint, which locks the orientation to the root part, you can use a Motor6D or set the CFrame of the aura relative to the head’s LookVector.

i need it to be weldconstraint on to the humanoidrootpart, as the whole game checks if like u have aura in there and so on

This approach keeps the WeldConstraint for the aura, while also setting the correct orientation based on the head’s direction (LookVector).

Let me know if there is any issues


if aura.Value == "Clock" then
	local auratoclone = game.ReplicatedStorage:WaitForChild("Auras").ClockAura
	local newaura = auratoclone:Clone()
	newaura.Parent = rootpart
	newaura.Position = rootpart.Position
	newaura.Name = "CurrentAura"
	
	-- Create a WeldConstraint to attach the aura to the HumanoidRootPart
	local weldconstraint = Instance.new("WeldConstraint")
	weldconstraint.Parent = newaura
	weldconstraint.Part0 = newaura
	weldconstraint.Part1 = rootpart
	
	-- Adjust the orientation to follow the player's head LookVector
	local head = rootpart.Parent:WaitForChild("Head")
	newaura.CFrame = CFrame.new(newaura.Position) * CFrame.Angles(0, head.CFrame.LookVector.Y, 0)
end

1 Like

it works but it changed the body orientation can it change the aura instead or can it only be body?

also i added a button for changing auras and if i switch between this aura and a different aura continuously, it stops making it rotated where the head is looking

Try this


local function setAuraOrientation(aura, rootpart, head)
	if aura then
		aura.CFrame = rootpart.CFrame * CFrame.new(0, 3, 0) * CFrame.Angles(0, math.atan2(head.CFrame.LookVector.X, head.CFrame.LookVector.Z), 0)
	end
end

local function onAuraSwitched(newAura)
	local head = rootpart.Parent:WaitForChild("Head")
	local currentAura = rootpart:FindFirstChild("CurrentAura")

	if currentAura then
		currentAura:Destroy()
	end
	
	local auratoclone = game.ReplicatedStorage:WaitForChild("Auras")[newAura]
	local newaura = auratoclone:Clone()
	newaura.Parent = rootpart
	newaura.Name = "CurrentAura"
	
	local weldconstraint = Instance.new("WeldConstraint")
	weldconstraint.Parent = newaura
	weldconstraint.Part0 = newaura
	weldconstraint.Part1 = rootpart
	
	setAuraOrientation(newaura, rootpart, head)
end

game:GetService("RunService").RenderStepped:Connect(function()
	local currentAura = rootpart:FindFirstChild("CurrentAura")
	if currentAura then
		local head = rootpart.Parent:WaitForChild("Head")
		setAuraOrientation(currentAura, rootpart, head)
	end
end)


its a server script, and i need something small and simple, bcuz theres a lot of other stuff in the full script

I’ve made it a bit easier to read, but I can’t make it smaller than it is.


local function setAuraOrientation(aura, rootpart, head)
	if aura then
		aura.CFrame = rootpart.CFrame * CFrame.new(0, 3, 0) * CFrame.Angles(0, math.atan2(head.CFrame.LookVector.X, head.CFrame.LookVector.Z), 0)
	end
end

local function switchAura(newAura, rootpart)
	local head = rootpart.Parent:WaitForChild("Head")
	local currentAura = rootpart:FindFirstChild("CurrentAura")

	if currentAura then
		currentAura:Destroy()
	end
	
	local auratoclone = game.ReplicatedStorage:WaitForChild("Auras")[newAura]
	local newaura = auratoclone:Clone()
	newaura.Parent = rootpart
	newaura.Name = "CurrentAura"

	local weldconstraint = Instance.new("WeldConstraint")
	weldconstraint.Parent = newaura
	weldconstraint.Part0 = newaura
	weldconstraint.Part1 = rootpart

	setAuraOrientation(newaura, rootpart, head)
end

game:GetService("RunService").RenderStepped:Connect(function()
	local currentAura = rootpart:FindFirstChild("CurrentAura")
	if currentAura then
		local head = rootpart.Parent:WaitForChild("Head")
		setAuraOrientation(currentAura, rootpart, head)
	end
end)




cant i just like do:

newaura.Orientation = head.Orientation

Yea it would still work the same way.

so ur saying i can do the 20-30 lines u did in 1 line i told

Maybe? I’m not sure though, try it out.

hm ok ill try it out rn

char limit

my line works perfectly fine…

char limit

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.