local guns = script.Guns:GetChildren() --- GUNS FOLDER
local Holders = GunSystemFolder.GunHolders:GetChildren() --- HOLDER FOLDER
print(guns)
print(Holders)
for i,H in pairs(Holders) do
if H.GunAssigned.Value then -- IF THE VALUE EXIST
local Gun = H.GunAssigned.Value --- THE OBJECT VALUE
local clone = Gun:Clone() -- CLONE THE PART IN THE OBJECT VALUE
clone.Parent = GunSystemFolder.Guns -- ASSIGN PARENT TO THE CLONED PART
print(clone.PrimaryPart.Name) -- PRINT THE NAME OF A PART INSIDE THE CLONED PART
-----------------------THE PROBLEM^
--clone.PrimaryPart.CFrame = CFrame.new(H.Position)
end
end
Error:
Players.OriginalEngineer.PlayerGui.GunShop.GunShopHandler:81: attempt to index nil with 'Name' - Client - GunShopHandler:81
I am trying to access a part of a cloned part of an Object Value.
So the order is local Object = H.GunAssigned.Value local CloneOfObject = Object:Clone
And then when I try to access the name a part called PrimaryPart inside the ClonedOfObject it returns attempt to index nil with 'Name'
Can you also help me with this?
I have clone.PrimaryPart.CFrame = CFrame.new(H.Position)
When it clones, the gun faces into weird positions, may I ask if there’s a way to set the new CFrame with it facing the correct direction?
Uh mb for the a bit late response… H doesn’t have a CFrame property?
When creating a new Identity CFrame, the rotational component is gonna be well obviously (0, 0, 0) and since Position properties don’t contain rotations / rotation matrices that means that the rotation will not “transfer”
The CFrame of H contains the rotation matrix while the Position doesn’t.
And I doubt that this is a GUI object since you’re setting the CFrame of a Part to this position so it probably has a CFrame property