Rotation of ImageLabel Do Not Stop:

Hello, there!

Currently, in Roblox Studio, I decided to make a little system that can slightly simulate the idea of the Roblox logo rotating once joining an experience and waiting for the game to be loaded in…

While putting upon the script to as well as change its TweenSize to 180 until 720, the last rotation value, 720, should’ve printed events saying that is loaded + changed the title of the TextLabel. However, testing by myself multiple times, either gives me an error throughout the Output or skips right away.

local RobloxLogo = script.Parent
local MainGui = game.StarterGui.MainGui
local LoadingFrame = MainGui.MainFrame.LoadingFrame
local LoadingFrameText = LoadingFrame.TextLabel

while true do
	wait(0.01)
	RobloxLogo.Rotation = script.Parent.Rotation + 1
	print(RobloxLogo.Rotation)
	if RobloxLogo.Rotation == 90 then
		wait(1)
		RobloxLogo:TweenSize(UDim2.new(0, 150, 0, 150), "Out", "Quad", 1)
		wait(3.5)
		RobloxLogo:TweenSize(UDim2.new(0, 100, 0, 100), "Out", "Sine", 1)
	end
	if RobloxLogo.Rotation == 180 then
		wait(1)
		RobloxLogo:TweenSize(UDim2.new(0, 150, 0, 150), "Out", "Quad", 1)
		wait(3.5)
		RobloxLogo:TweenSize(UDim2.new(0, 100, 0, 100), "Out", "Sine", 1)
	end
	if RobloxLogo.Rotation == 360 then
		wait(1)
		RobloxLogo:TweenSize(UDim2.new(0, 150, 0, 150), "Out", "Quad", 1)
		wait(3.5)
		RobloxLogo:TweenSize(UDim2.new(0, 100, 0, 100), "Out", "Sine", 1)
	end
	if RobloxLogo.Rotation == 720 then
		wait(1)
		RobloxLogo:TweenSize(UDim2.new(0, 150, 0, 150), "Out", "Quad", 1)
		wait(3.5)
		RobloxLogo:TweenSize(UDim2.new(0, 100, 0, 100), "Out", "Sine", 1)
		wait(5)
		local LoadingFrameText = "Carregado!" -- Carregado = Loaded
		if LoadingFrameText == "Carregado!" then
			print("Loaded")
			LoadingFrame:Destroy()
		else
			print("Error")
		end
	end
end

As the result, I was wondering if anyone can help me to make the rotation stop once at 720 and fire other events…

Just use break at the end of the while loop.

Also, @GuySalami, tweening does not always land on a perfect integer. I’ve tested it myself and got something like 7.2537 or some result like that. So, I think his process is better in this case.

Can’t you just use TweenService, and create a tween, for rotation = 720?

Edit, sample code:

local uiToRotate = nil -- replace with imageLabel
local info = TweenInfo.new(--[[fill in the info here]])

local tweenService = game:GetService("TweenService")

local tween = tweenService:Create(uiToRotate, info, {Rotation = 720})

tween.Completed:Connect(function(playBackState)
	-- after rotation ends, you can fire events from here
end)

tween:Play()

Use PlayerGui

local MainGui = game:GetService("Players").LocalPlayer.PlayerGui.MainGui

You would have to do something weird for a Tween not to land on a perfect integer, it used the similar math this method uses. And how did you get a:

From a tween, what was the endValue, and you should probably record that to Engine Bugs.

No, what I meant by that is my end-point was something way higher. But since he’s checking when his rotation reaches 90 then 180 then 360 then 720, he has to get an integer instead of a decimal. But in the middle of tween you wouldn’t get an integer. That’s why in his case, looping instead of looping is better.

I am quite not that good at using the TweenService, but according to the sample provided, I should put it like this:

local MainGui = game.StarterGui.MainGui
local LoadingFrame = MainGui.MainFrame.LoadingFrame
local LoadingFrameText = LoadingFrame.TextLabel

local uiToRotate = script.Parent -- I put script.Parent as the script is underneath the ImageLabel...
local info = TweenInfo.new(--[[fill in the info here]])

local tweenService = game:GetService("TweenService")

local tween = tweenService:Create(uiToRotate, info, {Rotation = 720})

tween.Completed:Connect(function(playBackState)
	local LoadingFrameText = "Carregado!" -- Carregado = Loaded
		if LoadingFrameText == "Carregado!" then
			print("Loaded")
			LoadingFrame:Destroy()
		else
			print("Error")
		end
end)

tween:Play()

(Uncertain how to put it exactly within the local variable Info, so I skipped it… I apologize)

As I put in my answer above, you should use PlayerGui, because it is the copy of StarterGui that is placed for the Player

local MainGui = game:GetService("Players").LocalPlayer.PlayerGui.MainGui

Looks good! The docs have good, well, documentation on TweenInfo.

I’m confused here. Here you’re basically checking that
"Carregado!" == "Carregado!" which is basically true making the if statement useless.

I forgot to state that I actually did put this as well as with the note of @AridTheDev! However, pressing Play throughout Roblox Studio, does not rotate the ImageLabel and instantly destroys the frame itself.

I used the if statement to make sure entirely that it will print the value stating that this is correct + fire further events as while developing the script from the topic, slightly works within not giving errors, though do not deploy anything… :dizzy_face:

Are you checking the LoadingFrameText's text is "Carregado!"?

you could also do

repeat
logo.Rotation += .5 --or however much you want to increase the rotation
wait() --to prevent crash
until game:IsLoaded()

Yes! Otherwise, on the GUI (without modifying the script), it would just say, as for Text, “Carregando” (Loading in Portuguese)…

I’m not sure if this would work but try this:

local RobloxLogo = script.Parent
local MainGui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("MainGui")
local LoadingFrame = MainGui.MainFrame.LoadingFrame
local LoadingFrameText = LoadingFrame.TextLabel
local TweenService = game:GetService("TweenService")

local Tween = TweenService(RobloxLogo, TweenInfo.new(--[[Set the time and other info if needed.]], {
    Rotation = 720
})

Tween:Play()

Tween.Completed:Connect(function()
    if LoadingFrameText.Text == "Carregado" then
        print("Loaded")
        task.wait(0.1) -- Adding this wait just so the frame doesn't get destroyed instantly
        LoadingFrame:Destroy()
    end
end)

Note: Wrote the code here on the website so formatting might not be good and it may not work

Equal to a White true do loop

local RobloxLogo = script.Parent
local MainGui = game:GetService("Players").LocalPlayer.PlayerGui.MainGui
local LoadingFrame = MainGui.MainFrame.LoadingFrame
local LoadingFrameText = LoadingFrame.TextLabel


local RotInfo = TweenInfo.new(7.2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
local RotTween = game:GetService("TweenService"):Create(RobloxLogo, RotInfo, {["Rotation"] = 720})
RobloxLogo:GetPropertyChangedSignal("Rotation"):Connect(function()
	local R = math.round(RobloxLogo.Rotation)
	if R == 90 then
		RotTween:Pause()
		task.wait(1)
		RobloxLogo:TweenSize(UDim2.new(0, 150, 0, 150), "Out", "Quad", 1)
		task.wait(3.5)
		RobloxLogo:TweenSize(UDim2.new(0, 100, 0, 100), "Out", "Sine", 1)
		RotTween:Play()
	elseif R == 180 then
		RotTween:Pause()
		task.wait(1)
		RobloxLogo:TweenSize(UDim2.new(0, 150, 0, 150), "Out", "Quad", 1)
		task.wait(3.5)
		RobloxLogo:TweenSize(UDim2.new(0, 100, 0, 100), "Out", "Sine", 1)
		RotTween:Play()
	elseif R == 360 then
		RotTween:Pause()
		task.wait(1)
		RobloxLogo:TweenSize(UDim2.new(0, 150, 0, 150), "Out", "Quad", 1)
		task.wait(3.5)
		RobloxLogo:TweenSize(UDim2.new(0, 100, 0, 100), "Out", "Sine", 1)
		RotTween:Play()
	elseif R == 720 then
		RotTween:Pause()
		task.wait(1)
		RobloxLogo:TweenSize(UDim2.new(0, 150, 0, 150), "Out", "Quad", 1)
		task.wait(3.5)
		RobloxLogo:TweenSize(UDim2.new(0, 100, 0, 100), "Out", "Sine", 1)
		task.wait(5)
		RotTween:Pause()

		local LoadingFrameText = "Carregado!" -- Carregado = Loaded
		if LoadingFrameText == "Carregado!" then
			print("Loaded")
			LoadingFrame:Destroy()
		else
			print("Error")
		end
	end
end)
RotTween:Play()

If the rotation is always kept, remove RotTween:Play() and RotTween:Pause()

This shouldn’t be an issue, but most people use Tween:Play() after Tween.Completed.

It doesn’t matter since the event is occurring either ways. But putting the event listening code before calling the function is a good practice since then there shouldn’t be any problems with the event not functioning.

This worked! Although, the script is having difficulty changing the title of the LoadingFrameText's Text to Carregado! (except to print upon Output as Loaded)…