So i tried a script that regenerates models, but it just duplicates the model. Here is the script
model = script.Parent backup = model:clone() while true do wait(5) model:Destroy() model = backup:clone() model.Parent = game.Workspace model:makeJoints() end
Can i get help fixing it?
Version 1: Cloning (Duplication)
local model = script.Parent local cframe = model.Primary.CFrame local debris = game:GetService("Debris") while true do debris:AddItem(model, 5.001) local backup = model:Clone() wait(5) backup.Parent = workspace backup:SetPrimaryPartCFrame(cframe) backup:MakeJoints() end
Using the Debris
Service, we can remove the model after the clone is made.
Since we want it to appear where the first model was, we save the CFrame of the Model's PrimaryPart (make sure you have chosen one), then use :SetPrimaryPartCFrame()
to move the model to that location.
Version 2: Model Movement (Specific Case)
Assuming your model would not be destroyed / altered in anyway, you can simply use the :SetPrimaryPartCFrame()
to reset the model's position.
local model = script.Parent local cframe = model.Primary.CFrame while true do wait(5) model:SetPrimaryPartCFrame(cframe) end