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

How to wait until a script inside a cloned model finish? [closed]

Asked by 7 years ago
Edited 7 years ago

I have a Model (not ModelScript) this model contains a script, this script set the PrimaryPart. my problem is, when I clone the model, I need to use the function SetPrimaryPartCFrame(cframe), to position the model, like this:

local cframe = CFrame.new(0, 0, 0) --whatever position
local name = "model name"
local model = game.ReplicatedStorage:FindFirstChild(name):Clone()
--at this point, the cloned script in the model is running,
--but it's not finish
--so the PrimaryPart  of the model has not set
model:SetPrimaryPartCFrame(cframe)

Now I got this error Model:SetPrimaryCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this., So my question is: how to wait until the script in the model finish?

Any help will be appreciated.

0
just wait(1), or put that script inside the other script infront of it lol. RubenKan 3615 — 7y
0
I have to load like 200 model, I can't I make the user wait 5 minutes LordSalchipapas 96 — 7y
0
Set a primary part in the script lol RubenKan 3615 — 7y
0
I have like 200 model, the primary part is it's not the same in all the model, only the model inself know what part is the primary part, this is what you expect object orientation, stop say "lol" at the final of your coments LordSalchipapas 96 — 7y
View all comments (7 more)
1
if you select the model in studio you are able to click the box next to Primary Part to set its value, simply click the part you want to be the primary part. no code needed. User#5423 17 — 7y
0
nice, that is very use full, I did not think that was possible, thank you, you solved the problem LordSalchipapas 96 — 7y
0
Never do script cloning into Instances like that. Use one script. cabbler 1942 — 7y
0
Just to piss you off i'll put another lol in here, lol. RubenKan 3615 — 7y
0
lol ^ awfulszn 394 — 7y
0
lol ^ awfulszn 394 — 7y
0
Lol ^ RubenKan 3615 — 7y

Locked by RubenKan

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?