Invalid argument #2 (string expected, got Instance) but I gave it a string?

I am trying to get a marker to show when something happens.
However, I keep getting the annoying error

invalid argument #2 (string expected, got Instance) 

Yet I am passing in a string, not an instance.
I have tried making true to “true”, that didn’t work.
I have no idea what the problem is because I don’t see a problem but apparently Roblox does. :roll_eyes:

Script:

-- Toggle Marker
function toggleMarker(n,b) -- N = String (name of the marker), B = bool value (true/false)
	game.ReplicatedStorage.Markers[n].Config.Enabled.Value = b
end

-- Watch for fire put out

function watchForFirePutOut(b)
	local model = game.Workspace["Fire Buildings"][b]
	local fireLeft = false
	local smokeLeft = false
	while wait(.1) do
		smokeLeft = false
		fireLeft = false
		for _,v in pairs(model:GetDescendants()) do
			if v.Name == "Fire" then
				fireLeft = true
			elseif v.Name == "Smoke" then
				smokeLeft = true
			end
		end
		
		if fireLeft == false and smokeLeft == false then
			toggleMarker(b,"false")
			activeFire = false
		end
	end
end

-- Calling toggle marker and watch for fire put out
toggleMarker(game.Workspace["Fire Buildings"]:FindFirstChild(fireBuilding),"true")
watchForFirePutOut(game.Workspace["Fire Buildings"]:FindFirstChild(fireBuilding).Name)

Like I said, I see no problem so I think Roblox is being a troller but I still wanted to make this post because maybe I did do something wrong :man_shrugging:

try this

-- Toggle Marker
function toggleMarker(n,b) -- N = String (name of the marker), B = bool value (true/false)
	game.ReplicatedStorage.Markers[n].Config.Enabled.Value = b
end

-- Watch for fire put out

function watchForFirePutOut(b)
	local model = game.Workspace["Fire Buildings"][b]
	local fireLeft = false
	local smokeLeft = false
	while wait(.1) do
		smokeLeft = false
		fireLeft = false
		for _,v in pairs(model:GetDescendants()) do
			if v.Name == "Fire" then
				fireLeft = true
			elseif v.Name == "Smoke" then
				smokeLeft = true
			end
		end
		
		if fireLeft == false and smokeLeft == false then
			toggleMarker(b,"false")
			activeFire = false
		end
	end
end

-- Calling toggle marker and watch for fire put out
toggleMarker(game.Workspace["Fire Buildings"]:FindFirstChild(fireBuilding).Name,"true")
watchForFirePutOut(game.Workspace["Fire Buildings"]:FindFirstChild(fireBuilding).Name)
2 Likes

This is a instance, not a string.

1 Like

feels like a complete idiot and asks Roblox to delete this threat

I spent ~45 minutes trying to figure out what was wrong…

You should give @kittyPGR the solution, mainly because he said it much faster than me.

2 Likes