Trying to make a spinning gui do a full 360 and then vanishes and a diffrent gui appears in its place and does a full 360 and repeats that process this is the code that ive tried to make but instead it just makes the first gui spin around really fast.
local RunService = game:GetService(“RunService”)
local guiObject1 = script.Parent
local guiobject2 = guiObject1.Parent.Logo2
local degreesPerSecond = 100
while true do
wait(1)
repeat
wait()
local function onRenderStep(deltaTime)
local deltaRotation = deltaTime * degreesPerSecond
guiObject1.Rotation = guiObject1.Rotation + deltaRotation
end
RunService.RenderStepped:Connect(onRenderStep)
until guiObject1.Rotation == 0
guiObject1.Visible = false
guiobject2.Visible = true
repeat
wait()
local function onRenderStep(deltaTime)
local deltaRotation = deltaTime * degreesPerSecond
guiobject2.Rotation = guiobject2.Rotation + deltaRotation
end
RunService.RenderStepped:Connect(onRenderStep)
until guiobject2.Rotation == 0
guiobject2.Visible = false
guiObject1.Visible = true
end
Please give me some info on how to do this!
There will be a total of 5 guis but for now theres only 2.
Why tweenservice though? (Im a beginner scripter so i just look at the API refrence)
Ive updated the topic with better wording and a diffrent script that i tried.
I don’t claim that this is the absolute best way to do it but this worked for me and seems mildly efficient.
local TweenService = game:GetService("TweenService")
local guiObject1 = script.Parent
local guiobject2 = guiObject1.Parent.Logo2
-- Do this two times, one for each gui object
for i = 1,2 do
local currentGuiObject = nil
-- Set the correct gui object for this loop
if i == 1 then
currentGuiObject = guiObject1
elseif i == 2 then
currentGuiObject = guiobject2
end
currentGuiObject.Visible = true
-- Rotate 90 degrees every 1 second 4 times
for i = 1,4,1 do
local tweenInfo = TweenInfo.new(
1, -- This is the time of the tween. Make is shorter if you want it to move faster
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- RepeatCount (when less than zero the tween will loop indefinitely)
false, -- Reverses (tween will reverse once reaching it's goal)
0 -- DelayTime
)
local tween = TweenService:Create(currentGuiObject, tweenInfo, {Rotation = 90 * i})
tween:Play()
wait(1)
end
if currentGuiObject == guiObject1 then
currentGuiObject.Visible = false
end
end
If you wanted to add a delay before the second object appears and rotates you could put a wait() right before that last end. If any part of this code doesn’t work please let me know and I’ll attempt to fix it.
1 Like
It works! but it doesnt loop infinitly although that wont be that big of a deal once i get all the logos in thanks!
1 Like