I've been working on a code for someone's game to have engines spawn upon interacting with a UI, and the code is working, except that the engines have a set orientation they are seemingly randomly facing every time I try to spawn them in. They are all facing the same way in ServerStorage, so I don't understand why they change orientation once they spawn. I think there's an easy fix to it, I just don't have that knowledge since I'm fairly new to Roblox coding 🥲
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpawnEngineEvent = ReplicatedStorage:WaitForChild("SpawnEngine")
local Spawners = game.Workspace.Spawners
SpawnEngineEvent.OnServerEvent:connect(function(player, engineName)
local Engine = ServerStorage:FindFirstChild("Engines"):FindFirstChild(engineName)
if Engine then
for _, item in pairs(Spawners:GetDescendants()) do
if item:GetAttribute("Location") == 1 then
local clonedEngine = Engine:Clone()
clonedEngine.Name = player.Name .. 'sEngine'
clonedEngine.Parent = game.Workspace["Player's Engines"]
clonedEngine:PivotTo(CFrame.new(item.CFrame.Position))
--[need code here to fix the orientation of the engine]
item:SetAttribute("Location", 0)
end
end
end
end)