SetPrimaryPartCFrame only setting the CFrame of the PrimaryPart and not the entire model? I have never seen this bug before and cannot find anything about it searching around google. The script is as follows:
local TempHolder = Instance.new('Model')
local Base = Instance.new('Part',TempHolder)
Base.Size = Vector3.new(150, 1, 150)
Base.CFrame = CFrame.new(-257.999878, 0.500001013, 6005.99805, 1, 0, 0, 0, 1, 0, 0, 0, 1)
Base.Anchored = true
TempHolder.PrimaryPart = Base
local Walls = Instance.new('Folder', TempHolder)
local Paths = Instance.new('Folder', TempHolder)
TempHolder.Parent = workspace
TempHolder.PrimaryPart = Base
-- print(printTable(Data))
if success then
for _,v in pairs(Data.Purchases) do
if v then
if v.Name == 'Wall' then
local Model = Instance.new('Model')
Model.Name = 'Wall'
local WallPart = Instance.new('Part', Model)
WallPart.Anchored = true
WallPart.Transparency = 1
WallPart.Material = Enum.Material.SmoothPlastic
WallPart.Name = 'Hitbox'
WallPart.Size = Vector3.new(9, 12, 0.4)
local Pole1 = Instance.new('Part', Model)
Pole1.Shape = 'Cylinder'
Pole1.Name = 'Pole1'
Pole1.Anchored = true
Pole1.Transparency = 0
Pole1.Material = Enum.Material.SmoothPlastic
Pole1.Size = Vector3.new(9, 0.4, 0.4)
-- Pole1.CFrame = WallPart.CFrame + WallPart.CFrame.lookVector * 0.1
Pole1.CFrame = CFrame.new(v.Pole1X,v.Pole1Y,v.Pole1Z)
local Pole2 = Instance.new('Part', Model)
Pole2.Shape = 'Cylinder'
Pole2.Name = 'Pole2'
Pole2.Anchored = true
Pole2.Transparency = 0
Pole2.Material = Enum.Material.SmoothPlastic
Pole2.Orientation = Vector3.new(0,0,math.rad(90))
Pole2.Size = Vector3.new(9, 0.4, 0.4)
-- Pole2.CFrame = WallPart.CFrame + WallPart.CFrame.lookVector * -0.1
Pole2.CFrame = CFrame.new(v.Pole2X,v.Pole2Y,v.Pole2Z)
WallPart.Size = Vector3.new((Pole1.Position - Pole2.Position).Magnitude,9,0.4)
WallPart.CFrame = CFrame.new(
Pole1.Position + 0.5*(Pole2.Position - Pole1.Position),
Pole1.Position + 0.5*(Pole2.Position - Pole1.Position) + (Pole1.Position - Pole2.Position).Unit:Cross(Vector3.new(0,1,0))
)
Pole1.CFrame = Pole1.CFrame * CFrame.Angles(0,0,math.rad(90))
Pole2.CFrame = Pole2.CFrame * CFrame.Angles(0,0,math.rad(90))
local WallPart3 = Instance.new('Part', Model)
WallPart3.Anchored = true
WallPart3.Transparency = 0
WallPart3.Material = Enum.Material.SmoothPlastic
WallPart3.Name = 'Wall1'
WallPart3.Orientation = Vector3.new(0,0,math.rad(90))
WallPart3.Size = WallPart.Size - Vector3.new(0,0,(WallPart.Size.Z/2))
WallPart3.CFrame = WallPart.CFrame + WallPart.CFrame.lookVector * 0.1
local WallPart4 = Instance.new('Part', Model)
WallPart4.Anchored = true
WallPart4.Transparency = 0
WallPart4.Material = Enum.Material.SmoothPlastic
WallPart4.Name = 'Wall2'
WallPart4.Orientation = Vector3.new(0,0,math.rad(90))
WallPart4.Size = WallPart.Size - Vector3.new(0,0,(WallPart.Size.Z/2))
WallPart4.CFrame = WallPart.CFrame + WallPart.CFrame.lookVector * -0.1
Model.PrimaryPart = WallPart
Model.Parent = TempHolder
---
elseif v.Name == 'Path' then
local Model = Instance.new('Model')
Model.Name = 'Path'
local WallPart = Instance.new('Part', Model)
WallPart.Anchored = true
WallPart.Transparency = 0
WallPart.Material = Enum.Material.SmoothPlastic
WallPart.Name = 'Hitbox'
local Pole1 = Instance.new('Part', Model)
Pole1.Shape = 'Cylinder'
Pole1.Name = 'Pole1'
Pole1.Anchored = true
Pole1.Transparency = 0
Pole1.Material = Enum.Material.SmoothPlastic
Pole1.Size = Vector3.new(0.2, 3, 3)
-- Pole1.CFrame = WallPart.CFrame + WallPart.CFrame.lookVector * 0.1
Pole1.CFrame = CFrame.new(v.Pole1X,v.Pole1Y,v.Pole1Z)
local Pole2 = Instance.new('Part', Model)
Pole2.Shape = 'Cylinder'
Pole2.Name = 'Pole2'
Pole2.Anchored = true
Pole2.Transparency = 0
Pole2.Material = Enum.Material.SmoothPlastic
Pole2.Size = Vector3.new(0.2, 3, 3)
-- Pole2.CFrame = WallPart.CFrame + WallPart.CFrame.lookVector * -0.1
Pole2.CFrame = CFrame.new(v.Pole2X,v.Pole2Y,v.Pole2Z)
WallPart.Size = Vector3.new((Pole1.Position - Pole2.Position).Magnitude,0.2,3)
WallPart.CFrame = CFrame.new(
Pole1.Position + 0.5*(Pole2.Position - Pole1.Position),
Pole1.Position + 0.5*(Pole2.Position - Pole1.Position) + (Pole1.Position - Pole2.Position).Unit:Cross(Vector3.new(0,1,0))
)
Pole2.CFrame = Pole2.CFrame * CFrame.Angles(0,0,math.rad(90))
Pole1.CFrame = Pole1.CFrame * CFrame.Angles(0,0,math.rad(90))
Model.PrimaryPart = WallPart
Model.Parent = TempHolder
else
if game.ReplicatedStorage.ItemHolder:FindFirstChild(v.Name) then
local Thing = game.ReplicatedStorage.ItemHolder[v.Name]:Clone()
Thing.Parent = TempHolder
Thing:SetPrimaryPartCFrame(CFrame.new(v.x,v.y,v.z))
end
end
end
wait()
end
TempHolder:SetPrimaryPartCFrame(Tycoon.Base.CFrame)
for _,v in pairs(TempHolder:GetChildren()) do
if v:IsA('Model') then
v.Parent = Tycoon.Purchases
end
end
for _,v in pairs(Walls:GetChildren()) do
if v:IsA('Model') then
v.Parent = Tycoon.Purchases.Walls
end
end
for _,v in pairs(Paths:GetChildren()) do
if v:IsA('Model') then
v.Parent = Tycoon.Purchases.Paths
end
end
TempHolder:Destroy()
end
I don’t know what is causing this as I have never had it before, any help would be appreciated, thanks!