Hello So I have a submarine game and in it I have a button that creates a torpedo model(before I had them already attacthed onto my sub) My problem is that when the sub moves to another area the models still spawn where the submarine first spawned. Here is the script.
model = script.Parent.Parent.torpeedo local backup = model:clone() model:Destroy() function onClicked() wait(1) model = backup:clone() model.Parent = game.Workspace model:makeJoints() end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Is is possible to make it so that it spawns near the ship even if it has moved away from its spawn. One option would be to mkae the model spawn in a part but I dont know how to do that. Thanks for your time!
I've changed your code a bit to make it work.
model = script.Parent.Parent.torpeedo local backup = model:clone() model:Destroy() function onClicked() wait(1) model = backup:clone() model.Parent = game.Workspace model:makeJoints() model:SetPrimaryPartCFrame(torpedoSpawn.CFrame) --add a part to reference were the torpedo should spawn end script.Parent.ClickDetector.MouseClick:connect(on
Make sure that the torpedo model has a primary part.