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

How Do I make this rotate my entire body?

Asked by 8 years ago
Player = game.Players.LocalPlayer
Character = Player.Character
Mouse = Player:GetMouse()

LeftShoulder = Character.Torso["Left Shoulder"]
RightShoulder = Character.Torso["Right Shoulder"]
LeftHip = Character.Torso["Left Hip"]
RightHip = Character.Torso["Right Hip"]

function LeftPunch(key)
    Key = key:lower()
    if Key == "q" then
        for i = 1, 1 do
            for i = 1, 10 do
                LeftShoulder.C0 = LeftShoulder.C0 *CFrame.Angles(0, 0, -0.25)
           Character.Torso.CFrame = CFrame.fromEulerAnglesXYZ(0,0,0)

                wait()
            end
            for i = 1, 10 do
                LeftShoulder.C0 = LeftShoulder.C0 *CFrame.Angles(0, 0, 0.25)
                wait()
            end
        end
    end 
end

function RightPunch()

end

function LeftKick()

end

function RightKick()

end

Mouse.KeyDown:connect(LeftPunch)
--I just want this to make me rotate to the right when I press q but formeulerangles doesnt do that what am I doing wrong?

2 answers

Log in to vote
1
Answered by
RedCombee 585 Moderation Voter
8 years ago
Edited 8 years ago

Your character isn't created by the time the script starts running, so you have to wait for the character.

Player = game.Players.LocalPlayer
Character = Player.CharacterAdded:wait() -- I'm using the CharacterAdded function here to pause the script until the character is added.
print(Player.Character.Name) -- This should print your character's name, just to make sure the character is loaded.
Mouse = Player:GetMouse()

LeftShoulder = Character.Torso["Left Shoulder"]
RightShoulder = Character.Torso["Right Shoulder"]
LeftHip = Character.Torso["Left Hip"]
RightHip = Character.Torso["Right Hip"]

function LeftPunch(key)
    Key = key:lower()
    if Key == "q" then
        for i = 1, 1 do
            for i = 1, 10 do
                LeftShoulder.C0 = LeftShoulder.C0 *CFrame.Angles(0, 0, -0.25)
           Character.Torso.CFrame = CFrame.fromEulerAnglesXYZ(0,0,0)

                wait()
            end
            for i = 1, 10 do
                LeftShoulder.C0 = LeftShoulder.C0 *CFrame.Angles(0, 0, 0.25)
                wait()
            end
        end
    end 
end

function RightPunch()

end

function LeftKick()

end

function RightKick()

end

Mouse.KeyDown:connect(LeftPunch)

Now, try your script. If that doesn't solve your problem, please come back and maybe we can help.

Ad
Log in to vote
1
Answered by
Unlimitus 120
8 years ago

Inside the HumanoidRootPart, there is a Motor6D called RootJoint. So what I would do is: ~~~~~~~~~~~~~~~~~ local rootJoint = Character.HumanoidRootPart:WaitForChild("RootJoint") rootJoint.C0 = rootJoint.C0 * CFrame.Angles(0, -30, 0) -- rotate -30 degrees ~~~~~~~~~~~~~~~~~

Hope this helps!

Answer this question