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

Make model spawn in a part even if the part changes position?

Asked by 4 years ago

Ive been trying to get this script working for over 2 hours now and still no luck. Here is the pic of the explorer: https://imgur.com/a/dNzP29d and here is the script:

model = script.Parent.Parent.torpedoSpawn.torpeedo
local backup = model:clone()
torpedoSpawn = script.Parent.Parent.torpeedo
model:Destroy()
function onClicked()
 wait(1)


    model = backup:clone()
    model.Parent = game.Workspace
    model:makeJoints()
    model:SetPrimaryPartCFrame(torpedoSpawn.CFrame) 

end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

Can someone please show me how the correct way looks like. Thanks for your time.

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

I would store the CFrame and also fix

model = script.Parent.Parent.torpeedo
local toorpedoSpawnCFRAME = model.torpeedoSpawn.CFrame
local backup = model:clone()
model:Destroy()
function onClicked()
 wait(1)


    model = backup:clone()
    model.Parent = game.Workspace
    model:makeJoints()
    model:SetPrimaryPartCFrame(toorpedoSpawnCFRAME) 

end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

You did toorpedoSpawn.toorpedo it was toorpedo.toorpedoSpawn Hope it works

Ad

Answer this question