How can I change bool value if object is not found?

Well I did try doing this but it doesn’t work. If there are any more posts about this then please share it. I’ll appreciate it!

Code
if not workspace:FindFirstChild("SpawnLocation") then
	workspace.Value.Value = true
end

Note: I tried this script in a blank baseplate just for testing.

  • AridFights1
1 Like

Show us the hierarchy of workspace please

1 Like

It’s just the normal baseplate but here you go; image

1 Like

the Value won’t change because there is SpawnLocation on the Workspace

1 Like

if there is no things named “SpawnLocation” then do this

Then should I use a for loop to check every time?

Now try this modified code, it should print something

you can just take off the not:

if workspace:FindFirstChild(“SpawnLocation”) then

Actually I’ll remove the “SpawnLocation” in the middle of the round.

if you do that, the Value will change for the boolean true

Alright so I fixed it. I just needed to use a while loop.

Code
while wait(1) do
	if not workspace:FindFirstChild("SpawnLocation") then
		workspace.Value.Value = true
		print("Value changed to " .. tostring(workspace.Value.Value))
	end
end

I forgot that the code I sent at the beginning, that only checks the first time, not every time

if you have only one “SpawnLocation” then yes it could work like that, else i would recommend to use a for loop