I want the desks to be placed parallel to each other when pressed, and a little more apart like this:
when I turn around, it’s different. I need help fixing them so that they are always positioned the way they are in the first picture.
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local PartSize = Vector3.new(1, 1, 0)
local PartSpacing = 6
local function CreateParallelParts(OriginPosition, AmountOfParts, LookVector)
for i = 1, AmountOfParts do
local Part = Instance.new("Part")
Part.Size = PartSize
Part.Anchored = true
Part.Parent = workspace
if i % 2 == 0 then
Part.Position = OriginPosition + LookVector * (i * PartSpacing)
else
Part.Position = OriginPosition + LookVector * (i * PartSpacing) - Vector3.new(-3, 0, 0)
end
end
end
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent then return end
if input.KeyCode == Enum.KeyCode.R then
local player = Players.LocalPlayer
local character = player.Character
local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
local OriginPosition = HumanoidRootPart.Position + HumanoidRootPart.CFrame.LookVector * 5
local AmountOfParts = 5
local LookVector = HumanoidRootPart.CFrame.LookVector
CreateParallelParts(OriginPosition, AmountOfParts, LookVector)
end
end)