Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why 'Workspace.SpawnObjects:3: attempt to call a nil value'?

while true do
	wait(0.5)
	spawnObj()
end

function spawnObj()
	local part = Instance.new("Part")
	part.Anchored = false
	part.Position = Vector3.new(1,50,4)
	
	part.Parent = game.Workspace
end

1 comment

0

could you mark my answer as solution

1 answer

✓ Accepted answer

Hey! In your code, spawnObj() is nil on line 3 because you haven't defined it. You'll have to move switch them to make it work.

function spawnObj()
    local part = Instance.new("Part")
    part.Anchored = false
    part.Position = Vector3.new(1,50,4)

    part.Parent = game.Workspace
end

while true do
    wait(0.5)
    spawnObj()
end

2 comments

1

I love you! Thanks soo much

0

np, accept answer if it worked

This discussion is preserved as it was. New answers, comments, and votes are closed.