1

# How do I keep models in workspace when they fall into the void without causing performance issues?

I recently fixed a respawn script and it works great, but when the objects fall into the void they stop spawning because they get deleted from workspace, meaning they cannot be respawned. Is there any loophole around this without major performance issues?

Here's the current code that I am using:

model = game.Workspace.Cars.RedCar1
backup = model:clone() -- backs up the model so it can respawn
while true do
wait(5) -- regenerates the model after 7 seconds

model = backup:clone() -- loads the backup of the model

model.Parent = game.Workspace
model:MoveTo(Vector3.new(-105.042,203.5,100.995))
end

0
You can always put the model in ReplicatedStorage. That's what I personally do and would recommend. ElBamino 153 — 3mo

0
ElBamino 153
3 months ago
Edited 3 months ago

So, to expand on my comment and explain it better. I recommend putting the model in ReplicatedStorage. This is extremely useful, it doesn't cause lag plus its always there when you need to clone it again! There's different ways to go about respawning (aka cloning) the model after this so below I will provide you with what I personally use. Also I highly recommend checking out this link! https://developer.roblox.com/en-us/api-reference/class/ReplicatedStorage

--First off you want to put your model in ReplicatedStorage
local model = game.ReplicatedStorage.Cars.RedCar1--im assuming this is your model so this is what I'll use
while true do
wait(5) -- regenerates the model after 5 seconds theres other BETTER ways to do this! you can always use a button or a ontouch function
backup = model:Clone() -- backs up the model so it can respawn
backup.Parent = game.Workspace
backup:MoveTo(Vector3.new(-105.042,203.5,100.995))
end
--i didnt test


Here's a on touch script that works!

local model = game.ReplicatedStorage.Cars.RedCar1
wait(1)
function onTouched(hit)
local check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
script.Parent.CanTouch = false
script.Parent.Transparency = 1
script.Parent.CanCollide = false
local backup = model:Clone()
backup.Parent = game.Workspace
-- you can use this to set the position versus where it was originally backup.Position = Vector3.new(-105.042,203.5,100.995)
wait(5)
script.Parent.CanCollide = true
script.Parent.Transparency = 0
script.Parent.CanTouch = true
end
end
end
script.Parent.Touched:Connect(onTouched)


I hope this helps you. I'm happy to help. If you have any questions don't hesitate to ask.

1
Thank you! woodboiz 11 — 3mo
1
Sorry to bother, but could you give a slight breakdown on how to use replicatedstorage? When I put models in there, they just disappear. woodboiz 11 — 3mo
0
Yeah they're suppose to "disappear", it puts them into storage so that you can call them through scripts! It's a nice way of keeping things in your case so you don't lose the model. You'll always be able to clone. Also you would put the on touch script inside of a part! ElBamino 153 — 3mo