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

My script is saying something doesn't exist when it clearly does in the explorer?

My script is telling me that an IntValue doesn't exist in a model when it does. I checked both server and client and confirmed the IntValue was there, I've tried WaitForChild and nothing worked. I just either got the error saying it didn't exist or Infinite time yield. I've searched online too, restarted roblox studio, turned on collab scripting, renamed the IntValue, deleted the IntValue and placed it back, and NOTHING worked! Please help!

(This is also a serverscript btw)

Also there's more code than this in the script but I shortened it to the important code and I don't believe the rest has anything to do with it.

if EValues.Floors.Value == 10 or EValues.Floors.Value == 20 then
		local NFloors = game.ServerStorage.NPCFloors:GetChildren()
		local RandomizedFloors = math.random(1, #NFloors)
		local RandomFloor = NFloors[RandomizedFloors]
		local CurrentFloor = Instance.new("Folder",game.Workspace)
		CurrentFloor.Name = "CurrentFloor"
		RandomFloor:Clone().Parent = CurrentFloor
		print(RandomFloor.Name)
		Timer.Value = RandomFloor:WaitForChild("Time").Value -- Errors here!
		Audio.Value = 0
		Intermission.Value = 0
		Monitor.SurfaceGui.Floorname.Text = 'Floor Name: '..RandomFloor.Name
		Monitor.SurfaceGui.Reset.Text = "There is a floor that's ongoing at the moment. If you reset to get back to the lobby or just came from the lobby you will not get Coins or Floors."
		wait(Timer.Value)
		Intermission.Value = 1
		EValues.Floors.Value = EValues.Floors.Value + 1
		Monitor.SurfaceGui.Floorname.Text = "Floor Name: None"
		Monitor.SurfaceGui.Floors.Text = 'Server Floors: '..EValues.Floors.Value
		game.ServerStorage.PlayerIntermission.Value = 1
		wait(2.5)
		Elevator.Monitor.Monitor.SurfaceGui.Reset.Text = "It is currently safe to reset to go back to the lobby without losing your reward for next floor. Get back to the elevator when Intermission is about to be over."
		Audio.Value = 1
		CurrentFloor:Destroy()
		Timer.Value = math.random(45, 60)
		wait(Timer.Value)
	end

1 answer

✓ Accepted answer

Roblox lua doesn't like it when you ask for something when its still loading try this:

	-- Add this below your RandomFloor Variable 
		local RF_Time = RandomFloor:WaitForChild("Time",10) -- wait 10 secs!
		--optional to add this next line below the above line.

		if(RF_Time == nil) then error("Error: Time not found in ",tostring(RandomFloor)," !! ") end

--		replace this:
		Timer.Value = RandomFloor:WaitForChild("Time").Value

-- 		with:
		Timer.Value = RF_Time.Value -- Errors here!

Code in Full:

if EValues.Floors.Value == 10 or EValues.Floors.Value == 20 then
        local NFloors = game.ServerStorage.NPCFloors:GetChildren()
        local RandomizedFloors = math.random(1, #NFloors)
        local RandomFloor = NFloors[RandomizedFloors]
        local CurrentFloor = Instance.new("Folder",game.Workspace)
	local RF_Time = RandomFloor:WaitForChild("Time",10)
	if(RF_Time == nil) then error("Error: Time not found in ",tostring(RandomFloor)," !! ") end
	Timer.Value = RF_Time.Value -- Errors here!
        CurrentFloor.Name = "CurrentFloor"
        RandomFloor:Clone().Parent = CurrentFloor
        print(RandomFloor.Name)
        Timer.Value = RF_Time.Value -- Errors here!
        Audio.Value = 0
        Intermission.Value = 0
        Monitor.SurfaceGui.Floorname.Text = 'Floor Name: '..RandomFloor.Name
        Monitor.SurfaceGui.Reset.Text = "There is a floor that's ongoing at the moment. If you reset to get back to the lobby or just came from the lobby you will not get Coins or Floors."
        wait(Timer.Value)
        Intermission.Value = 1
        EValues.Floors.Value = EValues.Floors.Value + 1
        Monitor.SurfaceGui.Floorname.Text = "Floor Name: None"
        Monitor.SurfaceGui.Floors.Text = 'Server Floors: '..EValues.Floors.Value
        game.ServerStorage.PlayerIntermission.Value = 1
        wait(2.5)
        Elevator.Monitor.Monitor.SurfaceGui.Reset.Text = "It is currently safe to reset to go back to the lobby without losing your reward for next floor. Get back to the elevator when Intermission is about to be over."
        Audio.Value = 1
        CurrentFloor:Destroy()
        Timer.Value = math.random(45, 60)
        wait(Timer.Value)
    end

Hope this helps in debugging this :)

2 comments

0

yeah it hould :WaitForChild

0

Thanks a lot, I don't get why the 10 at the end of waitforchild made it work but it did!

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