Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

SetPrimaryPartCframe on a Clone?

I am trying to make a button that when clicked it will clone a model and will be positioned at a coordinate frame. However it seems to not be working. I have put it through printing tests and it all runs well but the output says "Could not cast vector3 coordinate". Because of this I changed it to cframe, here is the code.

script.Parent.MouseClick:Connect(function(plr)
	if game.Workspace.Data.Buildingname.Value == ("ArcherHut") then -- Checks for data
		local Clone = game.Workspace.ArcherHut:Clone()
		Clone.Parent = game.Workspace
		Clone.Name = ("Tile1")
		Clone:SetPrimaryPartCframe(CFrame.new(-731.5, 6.5, -2676.5)) -- What's not working
	end
end)    

1 answer

✓ Accepted answer

Hey wolftamer894,

I have just resolved this issue by resetting the Primary Part.

Here is my Workspace picture.

Workspace

Here is the new code: It's a very minor change however a PrimaryPart does not transfer between models:

script.Parent.MouseClick:Connect(function(plr)
	if game.Workspace.Data.Buildingname.Value == ("ArcherHut") then -- Checks for data
		local Clone = game.Workspace.ArcherHut:Clone()
		Clone.Parent = game.Workspace
		Clone.Name = ("Tile1")
		Clone.PrimaryPart = Clone["ArcherHut"] -- My primaryPart is called ArcherHut
		Clone:SetPrimaryPartCFrame(CFrame.new(-731.5, 6.5, -2676.5)) 
	end
end)    

Hope this helped. Any issues? Feel free to contact me!

Cheers, Orcazate

1 comment

0

I tried your method and the output just says "SetPrimaryPartCframe is not a valid member of "Workspace.ArcherHut1" "

This discussion is preserved as it was. New answers, comments, and votes are closed.