i have a block which the camera moves with that the player moves with WASD keys and basically the block moves correctly and everything but when i press A it doesnt move left it goes right. basically it moves a different direction according to the orientation of the player’s plot. how do i make it move in the correct direction?
here is the code for when the a key is pressed for example:
if input.KeyCode == Enum.KeyCode.A then
while userInputService:IsKeyDown(Enum.KeyCode.A) do
newPos.Value = Vector3.new(newPos.Value.X - 1, newPos.Value.Y, newPos.Value.Z)
task.wait(interval)
end
end
how do i implement this into my code tho, sorry i don’t totally understand. like how would i make it so when you press a it always moves the camera left
its not very efficient i’m gonna improve it once i get it working, i did what u said and changed it so the positive and negatives are correct, it now moves the correct position but only when the plot has a certain orientation. i have a separate script that moves a block, when the newpos value updates, then when the block moves the camera moves with it, i know its not efficient but it’s just so i can visualize it
local player = game.Players.LocalPlayer
local lot = game.Workspace:WaitForChild("Lots"):WaitForChild(player.Name)
local lapModel = lot:WaitForChild("LookAtPoint")
local opBlock = lot:WaitForChild("OverheadPoint")
local userInputService = game:GetService("UserInputService")
local newPos = script.Parent:WaitForChild("NewCamPos")
newPos.Value = Vector3.new(opBlock.Position.X,opBlock.Position.Y,opBlock.Position.Z)
local interval = .05
userInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
-- if build gui visible
if script.Parent.Visible == true then
-- w
if input.KeyCode == Enum.KeyCode.W then
while userInputService:IsKeyDown(Enum.KeyCode.W) do
newPos.Value = Vector3.new(newPos.Value.X, newPos.Value.Y, newPos.Value.Z + 1)
task.wait(interval)
end
end
-- a
if input.KeyCode == Enum.KeyCode.A then
while userInputService:IsKeyDown(Enum.KeyCode.A) do
newPos.Value = Vector3.new(newPos.Value.X + 1, newPos.Value.Y, newPos.Value.Z)
task.wait(interval)
end
end
-- s
if input.KeyCode == Enum.KeyCode.S then
while userInputService:IsKeyDown(Enum.KeyCode.S) do
newPos.Value = Vector3.new(newPos.Value.X, newPos.Value.Y, newPos.Value.Z - 1)
task.wait(interval)
end
end
-- d
if input.KeyCode == Enum.KeyCode.D then
while userInputService:IsKeyDown(Enum.KeyCode.D) do
newPos.Value = Vector3.new(newPos.Value.X - 1, newPos.Value.Y, newPos.Value.Z)
task.wait(interval)
end
end
end
end)