When tweening cframe it randomly rotates

Hey, could anyone help me with something, when I use the ability it rotates for some reason how do I stop this?

Code:

	-- Tweens --
	local E1Tween = TweenService:Create(E1Clone, TInfo1, {Transparency = 0, Size = Vector3.new(1.74, 6.63, 6.624), Orientation = Vector3.new(5000,E1Clone.Orientation.Y,0)})
	local E2Tween = TweenService:Create(E2Clone, TInfo1, {Transparency = 0, Size = Vector3.new(2.096, 7.983, 7.976), Orientation = Vector3.new(-5000,E1Clone.Orientation.Y,0)})
	local E3Tween = TweenService:Create(E3Clone, TInfo1, {Transparency = 0, Size = Vector3.new(0.727, 8.654, 8.647), Orientation = Vector3.new(5000,E1Clone.Orientation.Y,0)})
	local E4Tween = TweenService:Create(E4Clone, TInfo1, {Transparency = 0, Size = Vector3.new(2.052, 7.817, 7.810), Orientation = Vector3.new(-5000,E1Clone.Orientation.Y,0)})
	local SpinTween = TweenService:Create(E4Clone, TInfo1, {Transparency = 0, Size = Vector3.new(0.051, 9.349, 9.341), Orientation = Vector3.new(5000,E1Clone.Orientation.Y,0)})
	local E12Tween = TweenService:Create(E1Clone, TInfo2, {CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 500 + HumanoidRP.Position, HumanoidRP.Position)})
	local E22Tween = TweenService:Create(E2Clone, TInfo2, {CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 500 + HumanoidRP.Position, HumanoidRP.Position)})
	local E32Tween = TweenService:Create(E3Clone, TInfo2, {CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 500 + HumanoidRP.Position, HumanoidRP.Position)})
	local E42Tween = TweenService:Create(E4Clone, TInfo2, {CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 500 + HumanoidRP.Position, HumanoidRP.Position)})
	local Spin2Tween = TweenService:Create(SpinClone, TInfo2, {CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 500 + HumanoidRP.Position, HumanoidRP.Position)})

Your telling your tween to rotate that way.

I’m unsure what your doing with

Orientation = Vector3.new(5000,E1Clone.Orientation.Y,0)

since you didn’t provide further code, but I’m sure this is where the problem lies.

Here is the full code

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local AttackFolder = ReplicatedStorage:WaitForChild("Attacks").EnergyRing
local Spin = AttackFolder:WaitForChild("spin")
local E1 = AttackFolder:WaitForChild("spin").e1
local E2 = AttackFolder:WaitForChild("spin").e2
local E3 = AttackFolder:WaitForChild("spin").e3
local E4 = AttackFolder:WaitForChild("spin").e4

-- Tween Info --
local TInfo1 = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local TInfo2 = TweenInfo.new(1.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)


script.Parent:WaitForChild("RemoteEvent").OnServerEvent:Connect(function(player)
	local Humanoid = player.Character.Humanoid
	local HumanoidRP = player.Character.HumanoidRootPart
	
	local SpinClone = Spin:Clone()
	local E1Clone = E1:Clone()
	local E2Clone = E2:Clone()
	local E3Clone = E3:Clone()
	local E4Clone = E4:Clone()

	-- Clone Propersties --
	E1Clone:SetAttribute("Owner", player.Name)
	E1Clone.Parent = workspace
	E2Clone.Parent = workspace
	E3Clone.Parent = workspace
	E4Clone.Parent = workspace
	Spin.Parent = workspace
	E1Clone.CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 5 + HumanoidRP.Position, HumanoidRP.Position)
	E2Clone.CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 5 + HumanoidRP.Position, HumanoidRP.Position)
	E3Clone.CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 5 + HumanoidRP.Position, HumanoidRP.Position)
	E4Clone.CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 5 + HumanoidRP.Position, HumanoidRP.Position)
	SpinClone.CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 5 + HumanoidRP.Position, HumanoidRP.Position)
	E1Clone.Orientation += Vector3.new(0, 90,0)
	E2Clone.Orientation += Vector3.new(0, 90,0)
	E3Clone.Orientation += Vector3.new(0, 90,0)
	E4Clone.Orientation += Vector3.new(0, 90,0)
	SpinClone.Orientation += Vector3.new(0, 90,0)
	


	-- Tweens --
	local E1Tween = TweenService:Create(E1Clone, TInfo1, {Transparency = 0, Size = Vector3.new(1.74, 6.63, 6.624), Orientation = Vector3.new(5000,E1Clone.Orientation.Y,0)})
	local E2Tween = TweenService:Create(E2Clone, TInfo1, {Transparency = 0, Size = Vector3.new(2.096, 7.983, 7.976), Orientation = Vector3.new(-5000,E1Clone.Orientation.Y,0)})
	local E3Tween = TweenService:Create(E3Clone, TInfo1, {Transparency = 0, Size = Vector3.new(0.727, 8.654, 8.647), Orientation = Vector3.new(5000,E1Clone.Orientation.Y,0)})
	local E4Tween = TweenService:Create(E4Clone, TInfo1, {Transparency = 0, Size = Vector3.new(2.052, 7.817, 7.810), Orientation = Vector3.new(-5000,E1Clone.Orientation.Y,0)})
	local SpinTween = TweenService:Create(E4Clone, TInfo1, {Transparency = 0, Size = Vector3.new(0.051, 9.349, 9.341), Orientation = Vector3.new(5000,E1Clone.Orientation.Y,0)})
	local E12Tween = TweenService:Create(E1Clone, TInfo2, {CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 500 + HumanoidRP.Position, HumanoidRP.Position)})
	local E22Tween = TweenService:Create(E2Clone, TInfo2, {CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 500 + HumanoidRP.Position, HumanoidRP.Position)})
	local E32Tween = TweenService:Create(E3Clone, TInfo2, {CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 500 + HumanoidRP.Position, HumanoidRP.Position)})
	local E42Tween = TweenService:Create(E4Clone, TInfo2, {CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 500 + HumanoidRP.Position, HumanoidRP.Position)})
	local Spin2Tween = TweenService:Create(SpinClone, TInfo2, {CFrame = CFrame.new(HumanoidRP.CFrame.LookVector * 500 + HumanoidRP.Position, HumanoidRP.Position)})


	E1Tween:Play()
	E2Tween:Play()
	E3Tween:Play()
	E4Tween:Play()
	SpinTween:Play()
	wait(2)
	E12Tween:Play()
	E22Tween:Play()
	E32Tween:Play()
	E42Tween:Play()
	Spin2Tween:Play()
end)

This is for spinning it. Just to make it look better

Got it.

CFrame.new(HumanoidRP.CFrame.LookVector * 500 + HumanoidRP.Position, HumanoidRP.Position)

is this issue. The side of the ring is it’s front face, so when your telling it to face “HumanoidRP” it’s front face faces it. You can make adjustments to the model so it’s front face is the actual flat side of the ring, or write code that I prefer not to write. lol.

How would you adjust the model I’m terrible with that sort of stuff

Well since you made it so it tweens the individual parts, and they happen to meshes, I personally have no clue.

If this was my code, I’d tween a CFrame value instance, and just update the ring model instead of the individual parts to follow that value. That way, it’s front face is easily changeable with its primarypart, the code looks nice, and overall gives me a lot more freedom in playing around with it.

For future reference, this plugin is what I use to see faces.

Unfortunately if we really want to keep using this code, which I really don’t recommend, use this instead:

CFrame.new(HumanoidRP.CFrame.LookVector * 500 + HumanoidRP.Position, (HumanoidRP.CFrame.LookVector * 500 + HumanoidRP.Position) + HumanoidRP.CFrame.RightVector)

Instead of facing the character itself, it faces the same direction as that your humanoid is facing. This should give a good enough illusion that it’s facing the character.

1 Like

If you can could you show me an example of what you would do so I know for next time. But if you don’t want to its fine

For sure. Thanks for asking!

local ts = game:GetService("TweenService")

local model = game.Workspace.ModelTween
local cfval = Instance.new("CFrameValue") -- Create the value our model will be following

local cfvalevent = cfval.Changed:Connect(function()
	model:SetPrimaryPartCFrame(cfval.Value)
end)

local twn = ts:Tween() -- create tween here

twn.Completed:Connect(function()
	cfval:Destroy()
end)

See how neat that is?

You should turn this into a function :slight_smile:

2 Likes

This is great thanks again for all your help!

1 Like