Should i use the Angles in CFrame?

Hi :smile: !
I have a problem when I spawn my attack it works fine except that the angle of the attack is shifted and does not follow the humanoid root part

Do you think I should use CFrame.fromEulerAnglesXYZ ()?

(I’m new to scripting)

The script :

local Meshes = script.Meshes -- on reveille les darons pour trouver le fils inshallah

local RP = game:GetService("ReplicatedStorage")-- on invoque la fonction game get service
local TS = game:GetService("TweenService")

local Debris = game:GetService("Debris")

local LuneModule = {}
function LuneModule.Moon(Folder,Humrp)-- on créer la fonction et la renomme moon dans le folder(attaques stock dans un dossier tiboinshape) et humrp(humanoid)

	local meshes = {}

	local Lune = Meshes.Lune -- plus de local là que la variable et ses propriétés
	
	Lune.CFrame = Humrp.CFrame * CFrame.new(0,0,-3) -- on adapte on réflechi on s'adapte
	Lune.Size = Vector3.new(2.174, 23.626, 27.19) -- on prend toujours tout
	Lune.Orientation = Vector3.new(15, -90, 0)
	Lune.Parent = Folder
	table.insert(meshes, Lune)
	
	local vfxlunebas = Meshes.vfxlunebas
	vfxlunebas.CFrame = Humrp.CFrame * CFrame.new(0,2,-3)
	vfxlunebas.Size = Vector3.new(13.456, 27.5, 3.899)
	vfxlunebas.Orientation = Vector3.new(0, 180, -95)
	vfxlunebas.Parent = Folder
	table.insert(meshes, vfxlunebas)
	
	local vfxlunemid = Meshes.vfxlunemid
	vfxlunemid.CFrame = Humrp.CFrame * CFrame.new(0,4,-3)
	vfxlunemid.Size = Vector3.new(16.773, 17.001, 4.478)
	vfxlunemid.Orientation = Vector3.new(0, 180, -90)
	vfxlunemid.Parent = Folder
	table.insert(meshes, vfxlunemid)
	
	local vfxluneup = Meshes.vfxluneup
	vfxluneup.CFrame = Humrp.CFrame * CFrame.new(0,5,-3)
	vfxluneup.Size = Vector3.new(8.509, 17.679, 3.426)
	vfxluneup.Orientation = Vector3.new(0, 180, -95)
	vfxluneup.Parent = Folder
	table.insert(meshes, vfxluneup)

	TS:Create(Lune, TweenInfo.new(.1),{ Position =  Humrp.CFrame * Vector3.new(0, 0, -50)}):Play()
	TS:Create(vfxlunebas, TweenInfo.new(.1),{ Position =  Humrp.CFrame * Vector3.new(0, 2, -50)}):Play()

	TS:Create(vfxlunemid, TweenInfo.new(.1),{ Position =  Humrp.CFrame * Vector3.new(0, 4, -50)}):Play()

	TS:Create(vfxluneup, TweenInfo.new(.1),{ Position =  Humrp.CFrame * Vector3.new(0, 5, -50)}):Play()
		
	
end


return LuneModule

1 Like

Using the first part as an example, there are several things I would change that should hopefully make this system work like you want it to

The first two are in relation to the first bit of code where youre setting up the start position:

    local vfxlunebas = Meshes.vfxlunebas
	vfxlunebas.CFrame = Humrp.CFrame * CFrame.new(0,2,-3) -- 1st comment
	vfxlunebas.Size = Vector3.new(13.456, 27.5, 3.899)
	vfxlunebas.Orientation = Vector3.new(0, 180, -95) -- 2nd comment
	vfxlunebas.Parent = Folder
	table.insert(meshes, vfxlunebas)

The first comment marked above would likely be where you would use CFrame.Angles like youve said
That would look something like:

    vfxlunebas.CFrame = Humrp.CFrame * CFrame.new(0,2,-3) * CFrame.Angles(0,0,0)

With some angle offset which youd have to test around with to get perfect
I would likely try something like:

* CFrame.Angles(0,math.rad(-90),0) -- -90 degrees converted to radians using math.rad

The second comment is that setting the orientation after setting the CFrame just overrides the CFrames rotation which is probably not what you want, I would remove it

Third comment has to do with this piece of code:

TS:Create(vfxlunebas, TweenInfo.new(.1),{ Position =  Humrp.CFrame * Vector3.new(0, 2, -50)}):Play()

The use of Vector3.new in the second term would do something which you probably dont want it to do, that is it just multiplies the position giving sometimes weird results (cause its relative to the world origin)

What Im assuming youre trying to do is make it go forwards in front of the player, in which case youd do something like:

TS:Create(vfxlunebas, TweenInfo.new(.1),{ Position =  (Humrp.CFrame * CFrame.new(0, 2, -50)).Position}):Play()
--uses cframe math to position relative to character, then extracts position only

So to sum it up:

  1. Use CFrame.Angles when setting the initial CFrame, multiplied onto the cframe at the end of the whole phrase with some angle, probably (0,math.rad(-90),0)
  2. Remove the entire “.Orientation = …” line
  3. Use CFrame math to properly apply the offset just like it was demonstrated above

Hopefully that solves some of the problems

1 Like

Thank you for your answer
I just tested the script with what you told me by testing the 3 options in addition to deleting the Orientation, your explanation is really good maybe not modifying the math rad I would have a solution but for now it gives that

I would like to have the right attack in front of the character!

The script :

local Meshes = script.Meshes -- on reveille les darons pour trouver le fils inshallah

local RP = game:GetService("ReplicatedStorage")-- on invoque la fonction game get service
local TS = game:GetService("TweenService")

local Debris = game:GetService("Debris")

local LuneModule = {}
function LuneModule.Moon(Folder,Humrp)-- on créer la fonction et la renomme moon dans le folder(attaques stock dans un dossier tiboinshape) et humrp(humanoid)

	local meshes = {}

	local Lune = Meshes.Lune -- plus de local là que la variable et ses propriétés
	
	Lune.CFrame = Humrp.CFrame * CFrame.new(0,0,-3) * CFrame.Angles(0,math.rad(-90),0) -- on adapte on réflechi on s'adapte
	Lune.Size = Vector3.new(2.174, 23.626, 27.19) -- on prend toujours tout
	Lune.Parent = Folder
	table.insert(meshes, Lune)
	
	local vfxlunebas = Meshes.vfxlunebas
	vfxlunebas.CFrame = Humrp.CFrame * CFrame.new(0,2,-3) * CFrame.Angles(0,math.rad(-90),0)
	vfxlunebas.Size = Vector3.new(13.456, 27.5, 3.899)
	vfxlunebas.Parent = Folder
	table.insert(meshes, vfxlunebas)
	
	local vfxlunemid = Meshes.vfxlunemid
	vfxlunemid.CFrame = Humrp.CFrame * CFrame.new(0,4,-3) * CFrame.Angles(0,math.rad(-90),0)
	vfxlunemid.Size = Vector3.new(16.773, 17.001, 4.478)
	vfxlunemid.Parent = Folder
	table.insert(meshes, vfxlunemid)
	
	local vfxluneup = Meshes.vfxluneup
	vfxluneup.CFrame = Humrp.CFrame * CFrame.new(0,5,-3) * CFrame.Angles(0,math.rad(-90),0)
	vfxluneup.Size = Vector3.new(8.509, 17.679, 3.426)
	vfxluneup.Parent = Folder
	table.insert(meshes, vfxluneup)

	TS:Create(Lune, TweenInfo.new(.1),{ Position =  (Humrp.CFrame * CFrame.new(0, 0, -50)).Position}):Play()
	TS:Create(vfxlunebas, TweenInfo.new(.1),{ Position =  (Humrp.CFrame * CFrame.new(0, 2, -50)).Position}):Play()
	TS:Create(vfxlunemid, TweenInfo.new(.1),{ Position =  (Humrp.CFrame * CFrame.new(0, 4, -50)).Position}):Play()
	TS:Create(vfxluneup, TweenInfo.new(.1),{ Position =  (Humrp.CFrame  * CFrame.new(0, 5, -50)).Position}):Play()
		
	
end


return LuneModule

I would just try different values for the angle such as:
(0,math.rad(-90),0)
(0,math.rad(0),0)
(0,math.rad(90),0)
(0,math.rad(180),0)
And perhaps even changing the first and third values if needed

1 Like

Thanks you for the « angles » that work
:v::v:

2 Likes