I am trying to make a prop regenning script, and whenever it regens an error saying Attempt to index function with destroy. The error is at line 8.
local regenScript = script local ServerStorage = game:GetService("ServerStorage") local Workspace = game:GetService("Workspace") local regenProps = Workspace:WaitForChild("AllProps") local save = regenProps:Clone() local function regenProps() regenProps:Destroy() local newSave = save:Clone() newSave.Parent = Workspace newSave:MakeJoints() end while true do wait(180) regenProps() end
It didn't work because you've overridden the regenProps model with the function regenProps. Simply changing one of the variable's names will work. You don't need to clone the model at the beginning of the script. You also don't need to declare workspace
as a variable.
local regenScript = script local ServerStorage = game:GetService("ServerStorage") local Props = Workspace:WaitForChild("AllProps") local function regenProps() local new = Props:Clone() Props:Destroy() Props = new Props.Parent = workspace Props:MakeJoints() end while true do wait(180) regenProps() end
The problem here is you need to either change the function name regenProps()
or change the name of the variable local regenProps
to something else