So I’ve been working on a boss fight and been wanting to add a little more detail. I’m trying to spawn smaller parts inside his laser beam attacks. I’m having some problems in testing though.
It seems whenever the main part is rotated the other parts do not follow the rotation.
Here is the code and I’m kind of clueless on how to fix this.
local PartToSpawnPartsIn = script.Parent
local PartClonable = game.ReplicatedStorage.Part
for i = 1, 100 do
local PartClone = PartClonable:Clone()
PartClone.Position = PartToSpawnPartsIn.Position
local ThingToDo = PartClonable.Size.X/2
local ThingToDo2 = PartClonable.Size.Z/2
local MaxX = (PartToSpawnPartsIn.Size.X/2)-ThingToDo
local MinX = (PartToSpawnPartsIn.Size.X/2)-((PartToSpawnPartsIn.Size.X/2)*2)+ThingToDo
local RandomX = (math.random(MinX,MaxX))
local MaxZ = (PartToSpawnPartsIn.Size.Z/2)-ThingToDo2
local MinZ = (PartToSpawnPartsIn.Size.Z/2)-((PartToSpawnPartsIn.Size.Z/2)*2)+ThingToDo2
local RandomZ = (math.random(MinZ,MaxZ))
PartClone.Position = PartClone.Position + Vector3.new(RandomX,0,RandomZ)
PartClone.Parent = workspace
end
I think you should try using CFrame instead of positioning, as setting the part’s CFrame will automatically rotate it to the rotation of the block you’re spawning it on