#Turn your character 180 degrees instantly

18 messages · Page 1 of 1 (latest)

pulsar sinew
#
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")

local UIS = game:GetService("UserInputService")

--|| Script ||--

UIS.InputBegan:Connect(function(input, gameProcessedEvent)

    if (input.KeyCode == Enum.KeyCode.S and UIS:IsKeyDown(Enum.KeyCode.Q)) or (input.KeyCode == Enum.KeyCode.Q and UIS:IsKeyDown(Enum.KeyCode.S)) then
        if tick() - PropertiesQ.LastDash >= PropertiesQ.Cooldown then
        end
    end
end)

Hello everyone, I'm making this post today because I have a serious problem with my script because a very important line of code is missing. I explain myself, recently I challenged myself to develop a game and right now I'm working on the controls (ex: dash...). However, on my dash script there is a line missing that would allow me to instantly turn my character in a direction to avoid dash bugs. Example: when I move forward with W and then I press S and Q my character instead of making a dash backwards it goes in all directions because my character makes a short rotation of 180 degrees, there is a certain latency that makes me not dash in the right direction. I thank you for your help!

ionic owl
#

Just rotate your character towards that direction depending on the rotation of the camera

#

If you wanted to dash forward for example, and your character is facing left (relative to your camera) then it will just rotate the character to face the direction of your camera

#

If that is what you are trying to solve

pulsar sinew
ionic owl
#

For now I just see the “cooldown”

pulsar sinew
ionic owl
#

Well you wanted to know where to put that line of code, and I recommend you put it inside of the drag script, now the controller script

burnt mirage
#

studio** You are now Level 6! **studio

pulsar sinew
burnt mirage
#

studio** You are now Level 1! **studio

ionic owl
#

so in what direction do you wanna dash

#

q is the dash key?

#

i don't even know if this will work

#
local UIS = game:GetService("UserInputService")
local camera = workspace.Camera

local character = script.Parent
local humanoidRP = character:WaitForChild("HumanoidRootPart")

function fixRotation()
    if humanoidRP and humanoidRP.Parent then
        local lvec, pos = camera.CFrame.LookVector, CFrame.new(humanoidRP.CFrame.Position)
        local x, y, z = humanoidRP.CFrame:ToEulerAnglesXYZ()

        if UIS:IsKeyDown(Enum.KeyCode.S) then
            humanoidRP.CFrame = pos * CFrame.fromEulerAnglesXYZ(x, -lvec.y, z)
        elseif UIS:IsKeyDown(Enum.KeyCode.W) then
            humanoidRP.CFrame = pos * CFrame.fromEulerAnglesXYZ(x, lvec.y, z)
        end
    end
end
#

since i don't mess with the rotation that much

ionic owl
#

@pulsar sinew