Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

3 comments

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.

0

that wasnt my question. my question was how do i make the player go right or left when pressed A or D.

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

1 answer

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

that should fix it

This discussion is preserved as it was. New answers, comments, and votes are closed.