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

Is there a way to remove player turn time?

Asked by
ItsMeKlc 235 Moderation Voter
7 years ago

Is there a way to remove the time it takes for a player to turn around? For my purposes I need for them to instantly turn around. I've thought about using BodyGyros, but I've never used that before so I'm not entirely sure how to go about it.

1 answer

Log in to vote
1
Answered by
brianush1 235 Moderation Voter
7 years ago

You could set the CFrame of the player's HumanoidRootPart on a key press. An example implementation could be the following. Note that this does not include diagonal angles, but it should be fairly easy to implement.

-- assuming this is a localscript inside the player's character
local RootPart = script.Parent.HumanoidRootPart
game:GetService("UserInputService").InputBegan:connect(function(Input, Event)
    if not game:GetService("UserInputService"):GetFocusedTextBox() then
        local Angles = CFrame.new(Vector3.new(), workspace.CurrentCamera.CFrame.lookVector * Vector3.new(1, 0, 1))
        if Input.KeyCode == Enum.KeyCode.W then
            RootPart.CFrame = CFrame.new(RootPart.CFrame.p) * Angles
        elseif Input.KeyCode == Enum.KeyCode.S then
            RootPart.CFrame = CFrame.new(RootPart.CFrame.p) * Angles * CFrame.Angles(0, math.pi, 0)
        elseif Input.KeyCode == Enum.KeyCode.A then
            RootPart.CFrame = CFrame.new(RootPart.CFrame.p) * Angles * CFrame.Angles(0, math.pi / 2, 0)
        elseif Input.KeyCode == Enum.KeyCode.D then
            RootPart.CFrame = CFrame.new(RootPart.CFrame.p) * Angles * CFrame.Angles(0, -math.pi / 2, 0)
        end
    end
end)
0
Wow works like a charm! Thank you so much! ItsMeKlc 235 — 7y
Ad

Answer this question