Why wont this respawn the object? Code Printed below
local PP = game:GetService("PointsService")
local Money = {}
local Luck = game.Workspace.Settings.PPRate
local function getParts(obj)
for i,v in pairs(obj:GetChildren())do
if obj:IsA("Part")then
table.insert(Money,obj)
end
getParts(v)
end
end
getParts(script.Parent)
function Touch(plr,loot)
if not plr:FindFirstChild("leaderstats")then return end
local type = loot.Name
local add = loot.Amount.Value
plr.leaderstats[type].Value = plr.leaderstats[type].Value+add
local oldParent = loot.Parent
loot.Parent = nil
delay(5,function( )loot.Parent = oldParent end)
if PP then
if PP:GetAwardablePoints()>0 and math.random(1,100)< Luck.Value then
PP:AwardPoints(plr.userId,add)
end
end
end
function addPart(part)
local backup = part:Clone()
local parent = part.Parent
part.Touched:connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent)then
Touch(game.Players:GetPlayerFromCharacter(hit.Parent),part)
end
end)
end
for i=1,#Money do
if Money[i]:IsA("Part")then
addPart(Money[i])
end
end