Working on a GUI when I stumbled on an error with vector3's. An error on line 8
local function GenerateSelectionModel()
if SelectionModel then
SelectionModel:Destroy()
end
local Prefab = PrefabTable[SelectionNumber]
if Prefab then
SelectionModel = Prefab:Clone()
SelectionModel:SetPrimaryPartCFrame(CFrame.new(Mouse.Hit.p) * CFrame.Angles(0, math.rad(CurrentRotation), 0) * CFrame.new(SelectionModel:FindFirstChild("Compensation")) or {Value = Vector3.new() * CFrame.new(0, SelectionModel.PrimaryPart.Size.Y / 2, 0)})
local Cache = SelectionModel:GetDescendants()
Mouse.TargetFilter = SelectionModel
for i = 1, #Cache do
if Cache[i]:IsA("BasePart") then
Cache[i].Material = Enum.Material.Glass
if Cache[i]:IsA("UnionOperation") then
Cache[i].UsePartColor = true
end
if Cache[i]:IsA("Seat") then
Cache[i].Disabled = true
end
if Cache[i].Transparency ~= 1 then
Cache[i].Transparency = 0.5
end
Cache[i].CanCollide = false
end
end
if Equipped then
SelectionModel.Parent = PrefabsFolder
end
end
end
This is a local script inside StarterCharacterScripts; if you need more information do ask. Thanks

7 comments
can you explain the logic behind line 8?
There is a lot going on and you probably should use a variable to help with the readability of the code
I am using variables. That's mostly the reason on why im confused why this isnt working- if you're wondering the output this is it https://gyazo.com/576cd18835a6fa68b41505bd9be416be
because your code is extremely messy
Sorry for that
Is there anything im doing wrong though?
Like they said above, you should split that giant line into several variables so it would be like SetPrimaryPartCFrame(CFrame1 or CFrame2) that way you have at least a general idea of what is specifically erroring, it's very difficult with the amount of paranthesis currently to decipher the logic in it