Trying to rotate UI confetti effect

so im trying to rotate my shapes in the effect to make it have a full revolution but it doesn’t spin around unfortunately.

  • i set a random rotation for the shape to start with and the CFrame in the “goal” isnt behaving how i want to if that makes sense.

here’s the code:

function confettiModule.new(viewportframe, count)
	local self = setmetatable({}, confettiModule)
	self.confettiParts = {}
	self.tweenCompleted = false
	local rng = Random.new()
	local confettiShapes = game.ReplicatedStorage:FindFirstChild("confettiShapes")

	for c = 1, count, 1 do
		local viewportSize = viewportframe.AbsoluteSize
		local confettiPart = randomShape(confettiShapes)
		table.insert(self.confettiParts, confettiPart)
		confettiPart.Parent = viewportframe

		local startRotX = rng:NextNumber(-360, 360)
		local startRotY = rng:NextNumber(-360, 360)
		local startRotZ = rng:NextNumber(-360, 360)

		local x = rng:NextNumber(-35, 35)
		local y = rng:NextNumber(30, 50)
		local confettiSizeMultiplier = rng:NextNumber(-1.15, 1.35)
		local CF = CFrame.new(x,y,0) * CFrame.Angles(math.rad(startRotX), math.rad(startRotY), math.rad(startRotZ))
		confettiPart.CFrame = CF
		confettiPart.Name = "confetti_"..c
		confettiPart.Color = randombrightColor()
		confettiPart.Size = confettiPart.Size * confettiSizeMultiplier

		local time = rng:NextNumber(2, 3)
		local delay = rng:NextNumber(0, 0.2)
		local xRot = rng:NextNumber(-720, 720)
		local yRot = rng:NextNumber(-720, 720)
		local zRot = rng:NextNumber(-720, 720)
		local endX = rng:NextNumber(-25, 25)
		local endCF = CFrame.new(x, -40, 0)
		local rotation = CFrame.Angles(math.rad(xRot), math.rad(yRot), math.rad(zRot))
		local goal = {
			CFrame = endCF * rotation
		}

		local tweenInfo = TweenInfo.new(time, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, delay)
		local tween = tweenService:Create(confettiPart, tweenInfo, goal)
		tween:Play()
	end

e4aa2f784f0b3120079361abe9bf5496

i am pretty sure your not even tweening the rotation

2 Likes

you might just need to render step the rotation
doing one tween that leads to 720 (which is just 360*2, which is basically no rotation)
wouldn’t do anything

1 Like

Try this, instead of having the rotation part of the goal put it outside.

local endCF = CFrame.new(x, -40, 0) * CFrame.Angles(math.rad(xRot), math.rad(yRot), math.rad(zRot))

local goal = {
CFrame = endCF
}
1 Like

ah yea i was using cframe for the rotation and orientation did the job instead ty!

ive seen people use runservice for rotating but u can still use tween service using the orientation property to change a part’s rotation in a viewport frame. thanks a million for ur help tho wicked!! :slight_smile:

hey self, i tried that but unfortunately it wouldnt work for cframe in my case so i just did a quick test and used the orientation property to get it to work and that worked fine.

thanks for ur help regardless tho! :slight_smile:

1 Like

using the orientation property helped me rotate parts in a viewport frame in my case !

code:

local rs = game:GetService("RunService")
local vpf = script.Parent.ViewportFrame
local part = vpf.Part
local tweenservice = game:GetService("TweenService")
local rng = Random.new()

local function randomRotation()
	--returns anticlockwise / clockwise. either between -360 and -720 degrees or between 360 and 720 degrees. 
	return rng:NextNumber(360, 720) * (rng:NextInteger(0, 1) == 0 and -1 or 1)
	
	--returns anticlockwise / clockwise. either between -360 and -720 degrees or between 360 and 720 degrees. 
	--return rng:NextNumber(360, 720) * (rng:NextInteger(0, 1) * 2 - 1)
end

local function getTweenInfo(tweenTime)
	return TweenInfo.new(tweenTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
end

while true do
	local tweenTime = rng:NextNumber(2, 3.5)
	local randomRotX = randomRotation()
	local randomRotY = randomRotation()
	local randomRotZ = randomRotation()

	local tween = tweenservice:Create(part, getTweenInfo(tweenTime), {Orientation = Vector3.new(randomRotX, randomRotY, randomRotZ)})
	tween:Play()
	tween.Completed:Wait()
	task.wait(0.01)
end

model:

aa9f0c7cf184cdc465a22227500c2454

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