I'm trying to make something respawn after it is destroyed (should be easy) but I keep getting the error in the title. I'm not sure how to make it go away.
Here is the code -
while true do wait(.1) if not game.Workspace:FindFirstChild("resource") then print 'no resource' wait(2) game.Lighting.resource:Clone().Parent = game.Workspace 'spawned resource' end end
You forgot print
on line 7. Lua is interpreting the code as
blah.Parent = workspace("spawned resource")
-- a function call on workspace -- which is obviously not what you meant.
This is why it's bad that Lua made parenthesis optional around calling. Relatedly, you should not omit the parenthesis when calling.
Function calls ignore whitespaces. So doing this still works;
function a() end a ''
Why this is relevant information is because you failed to provide the print
function on line 7. Therefore, the script assumed you were calling a function 'Workspace' - But Workspace is not a function, thus the error.
while wait(.1) do if not game.Workspace:FindFirstChild("resource") then print 'no resource' wait(2) game.Lighting.resource:Clone().Parent = game.Workspace print 'spawned resource' end end