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

How would I go about fixing this problem I have with my fly tool?

Asked by 5 years ago
wait(2)

local player = game.Players.LocalPlayer
local BV = Instance.new("BodyVelocity", player.Character.HumanoidRootPart)
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
local UIP = game:GetService("UserInputService")
local camera  = workspace.CurrentCamera


UIP.InputBegan:Connect(function(Key)
    if Key.KeyCode == Enum.KeyCode.W then
        BV.Velocity = camera.CFrame.LookVector*100
    elseif Key.KeyCode == Enum.KeyCode.S then
        BV.Velocity = camera.CFrame.LookVector*-100
    elseif Key.KeyCode == Enum.KeyCode.A then
        BV.Velocity =  -(camera.CFrame.LookVector * camera.CFrame.Z) --faulty
    elseif Key.KeyCode == Enum.KeyCode.D then
        BV.Velocity =  -(camera.CFrame.LookVector *- camera.CFrame.Z) -- faulty
    end
end)

I am trying to make it so when you press A or D you go to the right or left always, taking camera CFrame into count. I got it on W and S but on A and D it just goes one direction no matter where I look. How do I fix this?

If you wanna try this out, put it in playergui and you will see what I mean.

0
It's like so with the W and S too, it only updates when you press it again, I will look if I can make the script better. Torren_Mr 334 — 5y
0
that wasnt my question. my question was how do i make the player go right or left when pressed A or D. Thesquid13 301 — 5y
0
Sorry, I don't know how to fix that script, I made a fly tool what you can use, but I couldn't fix the script in the way you want. https://www.roblox.com/library/3397327272/Fly-tool Torren_Mr 334 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

use for right camera.CFrame.Rightvector*100 use for left camera.CFrame.Rightvector*-100

that should fix it

Ad

Answer this question