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

How do i spawn a model in a specific position?

How do i spawn a model in a specific position?

2 answers

✓ Accepted answer

Lets use the :SetPrimaryPartCFrame() function to move the models

First make sure your model has a PrimaryPart set

Before you set the model's parent, use the function to set its position

local model=model
local position=Vector3.new(0,0,0)

--setprimarypartcframe take a cframe value which is applied to the model's primarypart
--the other parts are moved along with the primarypart
model:SetPrimaryPartCFrame(CFrame.new(position))

--spawn it
model.Parent=workspace

2 comments

0

good

0

Thank You!

Let's just pretend you want when a player touches or click a part, it spawns the part in that position? In this case we'd have to Clone it from ServerStoarge Do this: Place the block in that exact position and move it into ServerStorage Add a script to the block you want the player to touch or to click Write (for touching that part)

function(onTouched)

or for clicking a part (Use a click detector)

script.Parent.ClickDetector.MouseClick:connect(function(mouse)

Then add this script :

local storage = game:GetService("ServerStorage")
local part = storage["Part"]:Clone() -- Change "Part" to the part name.
part.Parent = game.Workspace

If you have any question, feel free to ask me!

1 comment

0

Thank You!

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