Is there any way to fix this script so that the 'local backup' is removed once the 'backup.Main.Owner.Value' becomes empty? I'm thinking I need some way of checking whether the Owner of the tycoon is still in the game and then to regenerate after they leave but I don't know how I would go about this without lagging up the game.
wait(1)
local model = game.ReplicatedStorage.Tycoon1
local floor = script.Parent.Floor
local backup = model:Clone()
backup.Parent = game.Workspace
backup.PrimaryPart = backup.Baseplate
wait(0.1)
backup:SetPrimaryPartCFrame(CFrame.new(floor.Position))
local function Regen()
backup:Destroy()
wait(1)
backup = backup:Clone()
backup.Parent = script.Parent
backup:MakeJoints()
end
while true do
wait(1.5)
if backup.Main.Owner.Value ~= "" then
if not game.Players:FindFirstChild(backup.Main.Owner.Value) then
Regen()
end
end
end
Any and all help is appreciated!

1 comment
game.Players.PlayerRemoved