How to make it where my script works in both Roblox Studio AND Roblox

I’m working on a new choose your own adventure story, and I want to make it where when you load into the game, and you are greeted with an old 80’s computer boot up screen. So I was making it where at one point in the boot-up when it reaches the part where it says “USB Device(s):”, then, if you are playing with a touch screen then it says “1 touchscreen”, and if you aren’t playing with a touch screen, it says “1 keyboard and 1 mouse(and/or) 1 controller”.

When I try it in the emulator within Roblox Studio, it works. But when I go to play on mobile in Roblox it says “1 keyboard and 1 mouse(and/or) 1 controller”.

These errors kept popping up saying
" Players.anderdees4857743754.PlayerGui.ScreenGui.Frame.TextLabel.Script:30: Expected ‘end’ (to close ‘function’ at line 1), got ; did you forget to close ‘then’ at line 27?", which I discovered that this error popped up here because it needed 2 ends instead of 1.

if 'mobile' then
	   _G.GS = "  1 touch screen, 1 Storage device, 1 Hub" 
   end

Then I changed it to this…

if 'mobile' then
	   _G.GS = "  1 touch screen, 1 Storage device, 1 Hub" 
   end
end

The error went away. I looked around on dev forum, but I couldn’t find anything that could help me. Now for this I’m using 2 scripts. Here’s the first one:

function TabletOrPhone()

	if game:GetService('UserInputService').TouchEnabled == false then

		print 'Computer'

	else

		function TabletOrPhone()

			if game:GetService('UserInputService').TouchEnabled == true then

				print 'mobile'

			end
        end




   if 'mobile' then
	   _G.GS = "  1 touch screen, 1 Storage device, 1 Hub" 
   end				
end		
		
		
   if 'Computer' then 
	   _G.GS = "  1 keyboard, 1 Storage device, 1 Hub"
	end 
end

Now the second script is way to long. I know I’ll prob get replies saying that there is much simpler and easier way to write it, but this is the way I prefer to write it. Anyways, here’s the script:

Here’s a link to the game so far: computer? - Roblox

Finally, here’s a link to the video with a boot up screen that I based my design off of: Old Computer Boot Up Screen - YouTube

Nice start.
With regards to the errors, I think the nested function hides the normal syntax checks. You can remove the nested function and just use:

	if game:GetService('UserInputService').TouchEnabled == false then
		print 'Computer'
	elseif game:GetService('UserInputService').TouchEnabled == true then
				print 'mobile'
			end
		end

		if 'mobile' then
			_G.GS = "  1 touch screen, 1 Storage device, 1 Hub" 
		end				
	end

A couple of pointers:

  1. In the initial “booting…” message, use a loop for a few seconds to increase the number of dots, then resets:
    booting.
    booting…
    booting…
    A static message might imply an immediate boot failure.
  2. I think bus speed, memory frequency and cpu speed were all intrinsically linked in the olden days. However, my memory may be hazy.
  3. It looks as if you are booting to DOS. Prompt should be C:\

I really like it when people make things like this, almost like digging the pyramids and uncovering ancient artifacts.

1 Like

ok so I read your reply. I can’t do C:\ since it thinks I’m trying to do an actual command and doesn’t display the / so ultimately I’m doing this “C:/”. I also decided just to change it to just say 1 keyboard, because I’m gonna try to make the GUI into a surface GUI.