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

Why does the Angle reset?

Asked by 8 years ago
local run = game:GetService("RunService").RenderStepped


local keyheldq = false
local keyhelde = false

function onKeyPressQ(inputObject, gameProcessed)
    if inputObject.KeyCode == Enum.KeyCode.Q then
        keyheldq = true
        while keyheldq do

        torsorot = 0
        local rot = 0

        while torsorot < 100 do

            torso.CFrame = CFrame.new(torso.Position) * CFrame.Angles(0, rot, 0)

            rot = rot + .01

            print(rot)
            run:wait()
        end


            wait()
        end
    end
end


function onKeyReleaseQ(inputObject, gameProcessed)
    if inputObject.KeyCode == Enum.KeyCode.Q then
    print("Stopped holding the Q!")
    torsorot = 100
    torso.CFrame = CFrame.new(torso.Position)
        keyheldq = false
    end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPressQ)
game:GetService("UserInputService").InputEnded:connect(onKeyReleaseQ)

When the key Q is released, it doesn't stay at the Angle, it resets the angle to 0 again, and it doesn't stay,

I'm trying to make a character customization menu.

This is for character rotation as you might noticed.

0
Try making the rotation variable go through the entire script. This will mean you won't have to redefine it every time you want to make a change etc. TheDeadlyPanther 2460 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

Line 36

torso.CFrame = CFrame.new(torso.Position). You just reset the angle. Unless the thing is going to move, don't even bother setting the Position with it.


On a side note, if you're planning on making it rotate the other direction, you might want to take rot out of that loop so that you can keep it between events.

0
How did you get that line in between paragraphs? I've been trying to figure out how to do it for a while. TheDeadlyPanther 2460 — 8y
0
--- or *** with a line of clearance on either side. User#6546 35 — 8y
0
It's only worked with _________ for me... Perci1 4988 — 8y
0
Thanks! TheDeadlyPanther 2460 — 8y
0
Thanks! TheDeadlyPanther 2460 — 8y
Ad

Answer this question