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

How to make a rotation more than 1 time?

Asked by 3 years ago
Edited 3 years ago

Ok. I have a rotating part, but for some reason it can rotate only 1 time. Idk why.

            local number1 = part.Rotation.Z
            local number2 = number1 + 90
            print(number1)

                UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
                    if Input.KeyCode == Enum.KeyCode.R then
                    part.Rotation = Vector3.new(90, 0, number2)

1 answer

Log in to vote
0
Answered by
Sulu710 142
3 years ago

You need to update number2 as the rotation changes. Change it to this:

    UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
        if Input.KeyCode == Enum.KeyCode.R then
            local number1 = part.Rotation.Z
            local number2 = number1 + 90
            print(number1)
            part.Rotation = Vector3.new(90, 0, number2)

This way number2 will update every time depending on the part's rotation on that iteration, rather than remaining consistent to the part's starting rotation.

0
idk why, but when I insert your script, the part turns not 90, but in a random direction. to all this, the game is very laggy MiniMopsik 11 — 3y
0
ok. i fixed this. i just added debounce. anyway i accept your answer. MiniMopsik 11 — 3y
Ad

Answer this question