|
| 03 Oct 2014 09:07 PM |
I'd like to make a while loop, rotating a GUI continuously and seamlessly until you click a button. I don't know how to code the endless rotation efficiently, I can do the rest if I just have that part.
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 03 Oct 2014 09:24 PM |
| I'd say CFrame.angles. But in this case maybe theres a udim2.angles... |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 09:25 PM |
| yeah i haven't worked with guis in a while. |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 09:35 PM |
for i = 9, 0, -1 do survive.TextTransparency = i/10 wait() end
...Sort of what I'm trying to do, except with rotation and not transparency. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 03 Oct 2014 09:56 PM |
while wait() do gui.Rotation = gui.Rotation + 1 if gui.Rotation == 360 then gui.Rotation = 0 end end |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 10:03 PM |
it's that easy, huh?
thanks. |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 10:03 PM |
| Yeah rotation is a property in Gui objects |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 10:06 PM |
| i knew that part. just didn't get how to do anything else. xD |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 10:06 PM |
| Use >= though, == can get messy. |
|
|
| Report Abuse |
|
|
| |
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 03 Oct 2014 10:07 PM |
while true do for r = 0, 359 do gui.Rotation = r wait(0.03) end end
As far as making it stop from a separate script, .Disable = true the script above
To disable it from the same script
local rotate = true thingYouClick.MouseButton1Click:connect(function() rotate = false end)
while rotate do for r = 0, 359 do gui.Rotation = r wait(0.03) end end |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 10:53 PM |
This is what I have:
survive = script.Parent.survive background = script.Parent.background play = script.Parent.play
wait(8) for i = 9, 0, -1 do survive.TextTransparency = i/10 wait() end wait(2)
local rotate = true play.MouseButton1Click:connect(function() rotate = false end)
while rotate do for r = 0, 359 do survive.Rotation = r wait(0.03) end end
wait(5) for i = 1, 10 do survive.TextTransparency = i/10 end
That's the entire script, my sourcing is correct, but when you click play it does nothing. |
|
|
| Report Abuse |
|
|
|
| 03 Oct 2014 10:57 PM |
survive = script.Parent.survive background = script.Parent.background play = script.Parent.play
wait(8) for i = 9, 0, -1 do survive.TextTransparency = i/10 wait() end
wait(2)
rotate = true
play.MouseButton1Click:connect(function() rotate = false end)
while rotate do for r = 0, 359 do survive.Rotation = r wait(0.03) end end
wait(5)
for i = 1, 10 do survive.TextTransparency = i/10 end
I'm not a good scripter, I do however believe that if you remove the "local" from the variable it will work. Since local variables don't work outside of their location. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 03 Oct 2014 11:01 PM |
survive = script.Parent.survive background = script.Parent.background play = script.Parent.play
wait(8) for i = 9, 0, -1 do survive.TextTransparency = i/10 wait() end wait(2)
local rotate = false play.MouseButton1Click:connect(function() rotate = true end)
while not rotate do for r = 0, 359 do survive.Rotation = r wait(0.03) if rotate then break end end end
wait(5) for i = 1, 10 do survive.TextTransparency = i/10 end |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 03 Oct 2014 11:05 PM |
Local variables should always be used Sometimes a slight workaround might be needed, but you can ALWAYS use them and always should
They work within scopes within a scope
if true then local a = true print(a) -->true if not false then print(a) -->true end end print(a) -->nil
The workaround
Sometimes you might for some reason need this
for _, v in pairs (game.Players:GetPlayers()) do if --[[something about the player]] then local a = v end end print(v.Name) -->error
You would make it local like this
local a; --Localizing a for _, v in pairs (game.Players:GetPlayers()) do if --[[something about the player]] then a = v --Still local because we already localized a end end print(v.Name) -->players name |
|
|
| Report Abuse |
|
|