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

Cloned model keeps disappearing?

Asked by 5 years ago

I'm relatively new to scripting and I tried making a script where a model from Lighting (specifically an NPC) would be cloned and placed into Workspace. I don't know if the model being an NPC has something to do with it disappearing after a second or because it has multiple parts.

wait(1)

game.Lighting.NPC:Clone().Parent = game.Workspace

0
Why did you put it in Lighting? User#19524 175 — 5y
0
I tried moving it to different places and changing the script according to where it is but it makes no difference. oranqebIiss 1 — 5y
0
Move it to SeverStorage or ReplicatedStorage. User#19524 175 — 5y
0
I tried doing that but the same thing still happens and its frustrating... oranqebIiss 1 — 5y
View all comments (3 more)
0
Did you try something like game.Lighting:WaitForChild("NPC"):Clone().Parent = game.workspace stepatron 103 — 5y
0
No , and I just tried it right now and it works!Thank you so much. oranqebIiss 1 — 5y
0
np stepatron 103 — 5y

1 answer

Log in to vote
-2
Answered by 5 years ago

When you clone a model into Workspace, you’ll never know where it spawns. Another error is you used Lighting as storage but that method is deprecated.

local npcClone = game:GetService("ServerStorage").NPC:Clone()

clone.Parent = game.Workspace

if clone:FindFirstChild"HumanoidRootPart" then
    clone.PrimaryPart = clone.HumanoidRootPart
    clone:SetPrimaryPartCFrame(CFrame.new(0, 1, 0))
end
0
I tried using this script and the NPC spawns the same way it would as in the other script but it still keeps disappearing.Perhaps the error keeps occurring because I used a Part (named "NPC")as a parent for the actual NPC model? I'm not really sure if that affects anything. oranqebIiss 1 — 5y
0
Have the NPC model not parented to anything else but one of the storage services and Workspace. Don’t parent it to any part. User#19524 175 — 5y
0
The NPC model is parented to SeverStorage but is says "NPC is not a valid member of ServerStorage." oranqebIiss 1 — 5y
0
But you have to set the cloned part as a variable. Parent itt to Workspace. User#19524 175 — 5y
0
Er I don't really know how to do that. All I have right now is the NPC in ServerStorage and the script in Workspace. oranqebIiss 1 — 5y
Ad

Answer this question