I'm making a game where you insult the tree and it will grow and I got this problem where it grows too big and it will fall into the void so how do I respawn it?
COMMUNITY QUESTION
How do I respawn an object when it fell into the void?
1 answer
I think you could do something like this
local ReplicatedStorage = game:GetService("Replicated Storage")
local SaveTree = ReplicatedStorage.Tree -- Put your tree in replicated storage so you can copy it from there later
local RunService = game:GetService("RunService") -- Doing this so you can check every frame for the tree dissapearing
local function respawnTree()
if game.Workspace.Tree then -----Change this part to be able to find the tree when the game starts
wait()
else
local Tree = SaveTree:Clone()
Tree.Parent = game.Workspace ------Change this too if you are changing the place to find the tree above
Tree.Name = "Tree"
Tree.Position = Vector3.new( -- Put in the place you want the tree to go to when it despawns and when is is first put into the world. If you want it to respawn in a different place than where is originally spawns then you need to put the tree where you want it to be when the game starts then type in the coordinates that you want it to respawn in here. If you will do the second option, you will have to change the place where the code can find the tree)
end
end
RunService.Heartbeat:Connect(function()
respawnTree
end)
Sorry if I was a bit confusing with this
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
I can't put it in replicated storage because then the tree script where it grows from hate words will go and thats the point of the game
I'm confused, what do you mean?