Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

SetPrimaryPartCframe on a Clone?

Asked by 3 years ago

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

Log in to vote
0
Answered by
orcazate 170
3 years ago
Edited 3 years ago

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

0
I tried your method and the output just says "SetPrimaryPartCframe is not a valid member of "Workspace.ArcherHut1" " wolftamer894 50 — 3y
Ad

Answer this question