Why am I getting this error?

So I keep getting this error message whenever I try to make a variable, both local and global. Why is this happening?
Screenshot_274
I am simply trying to define the variable clone as boss:Clone()

clone = boss:Clone()

What does this mean, and how do I fix it?

I’ve had this problem before but it’s caused by previous code that is missing an ending or a closing bracket. Can we see more of the code?

Sure.

bossName = "Dummy"

local boss = game.Lighting.Bosses:WaitForChild(bossName)
function regenboss()
	if workspace:FindFirstChild(bossName) then
	workspace:FindFirstChild(bossName):Destroy()
 	clone = boss:Clone()
	clone.Parent = workspace
	else
	local clone = boss:Clone()
	clone.Parent = workspace
end
end

This is everything to that point

Do you have the Luau VM Beta feature on? Your code looks to be fine and that error seems to be a bug, especially since the warn code is 000.

Yes I did have the lua VM on, but I turned it off and I’m still getting the error.

1 Like

Try writing it like this instead:

local boss = game.Lighting.Bosses:WaitForChild(bossName)
function regenboss()
    if workspace:FindFirstChild(bossName) then
        workspace:FindFirstChild(bossName):Destroy()
    end
    
    local clone = boss:Clone()
    clone.Parent = workspace
end

Since you’re always creating a clone in both cases.

It’s not an error, it’s a warning, it won’t affect your game, it won’t even put a warning into the output, it’s just something to assist you in developing, so you don’t have to run the game to notice those mistakes.

Edit: as another thing to take note of, don’t do this

if workspace:FindFirstChild(bossName) then
	workspace:FindFirstChild(bossName):Destroy()
end

Instead, do this

if workspace:FindFirstChild(bossName) then
	workspace[bossName]:Destroy() -- don't do FindFirstChild twice, it is faster to do this instead
end
1 Like

Yes I understand this, but I think it may be a bug because now It is saying it for end which comes even before I define clone.
Screenshot_275

Edit: Thanks for the advice.
Edit again: I accidentally left my “boss” variable as a local variable outside of the function. Now it works as a global variable.