TS.OnServerInvoke = function(player,car,hum,particle,Helmet,costume,copycat,weld) hum.WalkSpeed = 0 wait(0.5) local new = Instance.new("Animation") new.AnimationId = changeid local newtrack = hum:LoadAnimation(new) newtrack:Play() wait(1) costume = particle:Clone() costume.CFrame = car.UpperTorso.CFrame * CFrame.new(0,5,0) costume.Anchored = true costume.Parent = car.UpperTorso wait(1) hum:RemoveAccessories() copycat = Helmet:Clone() copycat.CFrame = car.Head.CFrame * CFrame.new(0,0.75,0) weld = Instance.new("Weld") weld.Parent = copycat weld.Part0 = car.Head weld.Part1 = copycat weld.C0 = car.Head.CFrame:Inverse() weld.C1 = copycat.CFrame:Inverse() copycat.Parent = game.Workspace car.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=53557909" car.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=53558597" wait(1) hum.WalkSpeed = 16 costume:Destroy() new:Destroy() return copycat,weld end TC.OnServerInvoke = function(player,car,hum,particle,Helmet,costume,copycat,weld,empty,ShirtId,Pants) hum.WalkSpeed = 0 wait(0.5) local Debris = game:GetService("Debris") local new = Instance.new("Animation") new.AnimationId = changeid local newtrack = hum:LoadAnimation(new) newtrack:Play() wait(1) costume = particle:Clone() costume.CFrame = car.UpperTorso.CFrame * CFrame.new(0,5,0) costume.Anchored = true costume.Parent = car.UpperTorso wait(1) Debris:AddItem(copycat) Debris:AddItem(weld) car.Shirt.ShirtTemplate = ShirtId car.Pants.PantsTemplate = Pants wait(1) hum.WalkSpeed = 16 costume:Destroy() new:Destroy() return copycat,weld end
So, I tried destroying a model in a remote function, but it didn’t work. I used Debris and Destroy and returned the function. Any idea ?
Maybe is because of your invoke method. Try using instead of
TS.OnServerInvoke = function()
write
local function function_name(player and etc) -- etc end TS.OnServerInvoke = function_name