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

[SOLVED] Workspace.Manage.RoomCheck:10: attempt to call global 'check' What's going on?

My script spits out Workspace.Manage.RoomCheck:10: attempt to call global 'check' (a nil value) What's going on?

Here's my code

-- Room Checker Script
local boardRooms = game.Workspace.Manage.SurfaceGui.Rooms
local roomDbase = game.ReplicatedStorage.RoomDatabase.Standard
Ok = Color3.new(0, 184, 6)
Ta = Color3.new(184,0,0)

repeat
  wait(15)
  -- Normal Rooms
  check("101")
  check("102")
  check("103")
  check("104")
  check("105")
  check("106")
  check("201")
  check("202")
  check("203")
  check("204")
  check("205")
  check("206")
  check("301")
  check("302")
  check("303")
  check("304")
  check("305")
  check("306")
  wait(1)
  -- Suite Rooms
  check("207S")
  check("208S")
  check("209S")
  check("210S")
  check("307S")
  check("308S")
  check("309S")
  check("310S")
  check("400S")
  wait(1)
until script.Parent == nil



function check(roomId)
  if roomDbase[roomId].Owner.Value ~= "" then
  	  boardRooms[roomId].BackgroundColor3 = Ta
    	boardRooms[roomId].N1.Text = roomDbase[roomId].Owner.Value
    	print("Room "..roomId.." assigned to board.")
  end
  if roomDbase[roomId].Owner.Value == "" then
  	  boardRooms[roomId].BackgroundColor3 = Ok
    	boardRooms[roomId].N1.Text = "Available"
    	print("Room "..roomId.." cleared from board.")
  end
end

10 comments

0

is check even a thing? i never heard of it, mayb thats whats wrong and its probarly considering it nil thats why

0

Yea i just checked it gave me same error, that's cuz check() isnt a thing? what r u doing?

0

check is a function. Look down in the code. It starts at line 44

0

ohh sorry i thought it wasa lua function :facepalm: lol i suck sorry

0

this script is not working cuz youre assigning the function, or we can say creating it after it being called

0

move your function creation part of the script all the way to the top, and see if it works

0

for the script, check isnt a thing yet, remember that your computer reads the script line by line, you were calling the function before assigning it

0

fixed?

0

did i help?

0

rude..

1 answer

✓ Accepted answer

You probably figured it out, but if you don't want to put the function in a certain order you can also put at the top of script

local check

So long as you finish defining it before you end up calling it. You can do that with your script by enclosing the lines 2 to 41 in a function and calling that function as the very last line of the script

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