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

"Else" statement does not seem to work?

So my code looks like this :

while wait() do
if game:GetService("Workspace").Map then
   codeeeee
else
      print("ok")
end
end

Output :

Map is not a valid member of Workspace

Shouldn't it print ok until the map spawns in?

2 answers

✓ Accepted answer

I don’t know if this is the “right” way to do it but I usually use

  if workspace:FindFirstChild(“Map”) ~= nil then
 else
 end

This works for me...

2 comments

0

let me try

0

it works tysmmmmmm

Just change the code to:

while wait() do
if workspace:FindFirstChild("Map") then
   --codeeeee
else
      print("ok")
end
end

8 comments

0

Doesn't work

0

Any errors? Where is your script located?

0

works for me

0

I think FindFirstChild returns nil if there is no child with that name.

0

So maybe nil does not equal false or true and causes an error?

0

It works for me

0

what about workspace.Map? i think that shoudl work right?

0

Erie20, workspace.Map wont work, but the strange thing is that my way dont worked for him which is kinda strange cuz it should work (Cuz im always using that way and its working for me)

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