How to make a part point to the right direction with CFrame?

I am trying to make a “speed of sound” effect (when something goes so fast that you get a “blow” on the air) and have been having trouble trying to do this for a couple hours.

I just want to angle the air blow with the character torso properly but the way this is working is not reliable since the angles are not 100% accurate and when i jump that effect points only to one side.

Example:

My current script:

local rushMode = game.ReplicatedStorage.RemoteStuff.RushMode
local speedBlow = game.ReplicatedStorage:FindFirstChild("SpeedBlowModel").SpeedBlow
local PointTarget = game.ReplicatedStorage:FindFirstChild("SpeedBlowModel").PointTarget

game.ReplicatedStorage.RemoteStuff.RushMode.OnServerEvent:Connect(function(player)
	local boostSound = player.Character.Humanoid.Parent.RushBar.RushSound
	local rushOn = player.PlayerInfo.RushActive
	local rushBar = player.PlayerInfo.RushBar
		rushOn.Value = 1
		local SpeedBlowFX = speedBlow:Clone()
		local PointTargetFX = PointTarget:Clone()
		SpeedBlowFX.Parent = game.Workspace
		PointTargetFX.Parent = game.Workspace
	    local x = player.Character.Torso.Position.X
	    local y = player.Character.Torso.Position.Y
	    local z = player.Character.Torso.Position.Z
	    local startPosition = Vector3.new(x,y,z)
	    local targetPosition = player.Character.Head.Position
        SpeedBlowFX.CFrame = CFrame.new(startPosition, targetPosition)
        local pointLight = Instance.new("PointLight")
        pointLight.Parent = player.Character.Torso
        pointLight.Color = Color3.fromRGB(255, 0, 0)
        pointLight.Brightness = 5
        pointLight.Range = 10
       
        
		print("FUNCIONOU???"..x..y..z)
		boostSound:Play()
		for i = 1, 0, -0.05 do
			boostSound.Volume = i
			wait()
		end
		wait(3)
		rushBar.Value = 0
		rushOn.Value = 0
		pointLight:Destroy()
		attach:Destroy()
end)

I don’t think i explained properly but i think it is understandable, i just need help getting the accuracy on the angle of that effect

Is the red ring the effect? From what I can tell, it seems to be facing the correct way. You might need to elaborate a little bit more if you can.

Yes

It is not that perceptive but if you pay close attention to the gif you’ll will see that when i Jump i activate the red ring and it faces the wrong direction.

The method i am using right now “KINDA” works but not 100% well

1 Like

Try changing the CFrame to this:

local RootLookVector = player.Character.HumanoidRootPart.CFrame.LookVector

 SpeedBlowFX.CFrame = CFrame.new(startPosition,startPosition + RootLookVector)

If the ring is not upright, you can use CFrame.Angles to rotate it.

I think the biggest problem i am having actually must be related to the ring not being upright from the beginning, would you mind showing me how to do it? (Your changes worked but the circle is facing up/down)

I’m not sure what axis is the correct one, but X normally does the trick. Add this to the end of the code above:

* CFrame.Angles(math.rad(90),0,0)

If it flips the ring up but the hoop is facing to the left and right of the character, try changing the math.rad portion to the Z axis.

1 Like

Problem solved. I spent like 2 or 3 hours trying to fix this on my own, i just lose the logic when i spend too much time on one thing xD

Thank you for your help!

1 Like