Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why will my gui not rotate as commanded?

Asked by 4 years ago

When I was working on my game I started trying to add more stuff into it, so I added a little script that rotates a gui. However the gui will not rotate, what did I do wrong?



while wait(1) do script.Parent.Rotation = script.Parent.Rotation - 1 repeat wait(1) until script.Parent.Rotation == -11 if script.Parent.Rotation == -11 then script.Parent.Rotation = script.Parent.Rotation + 1 repeat wait(1) until script.Parent.Rotation == 11 break end end
0
you should put the repeat outside TheRealPotatoChips 793 — 4y

2 answers

Log in to vote
0
Answered by
3132750 45
4 years ago

This might be what you're looking for:

while wait() do
    if script.Parent.Rotation >= 0 then
        repeat
            wait()
    script.Parent.Rotation = script.Parent.Rotation - 1
    until script.Parent.Rotation == -11
    end
    if script.Parent.Rotation < 0 then
        repeat 
            wait()
        script.Parent.Rotation = script.Parent.Rotation +1
        until script.Parent.Rotation == 11
    end
end
Ad
Log in to vote
0
Answered by 4 years ago

Try this:

local plus = false

while wait(1) do

    if plus == false then
        script.Parent.Rotation = script.Parent.Rotation - 1
    elseif plus == true then
        script.Parent.Rotation = script.Parent.Rotation + 1
    end

    if script.Parent.Rotation == -11 then
        plus = true
    elseif script.Parent.Rotation == 11 then
        plus = false
    end

end

Hope this helped!

Answer this question