generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Check if mobile script?

Previous Thread :: Next Thread 
wayne2018 is not online. wayne2018
Joined: 04 Jun 2014
Total Posts: 2509
30 Mar 2016 11:41 PM
So I've been trying to make a script that will make a certain GUI visible when a user is using a mobile device. I'm new to scripting and I got really confused and I need help...
This is literally my second script that I attempted to write so don't be harsh

if game:GetService("UserInputService").TouchEnabled == false then
script.Player.PlayerGui:FindFirstChild("GUI")
script.Parent.GUI.Visible = true
end

Report Abuse
NOTlaedere is not online. NOTlaedere
Joined: 06 Jul 2014
Total Posts: 1356
30 Mar 2016 11:47 PM
if game:GetService("UserInputService").TouchEnabled == false then
script.Player.PlayerGui:FindFirstChild("GUI")
script.Parent.GUI.Visible = true
end

You set the conditional on the first line to false, meaning if the actual user is on a mobile device, this won't activate. You need to make .TouchEnabled == true
Report Abuse
wayne2018 is not online. wayne2018
Joined: 04 Jun 2014
Total Posts: 2509
31 Mar 2016 12:44 AM
@NOTlaedere Yea, I know. I set it to false so that it would show up on the PC because I couldn't use my mobile device at that moment. If it showed up on PC then it would've meant that it works. However it didn't...
Report Abuse
TimeCruiser is not online. TimeCruiser
Joined: 24 Oct 2008
Total Posts: 134
31 Mar 2016 01:33 AM
The third line in your script should have been:
script.Parent.PlayerGui.GUI.Visible = true

If that change is not enough to fix it, then I suspect that the script is running before all of the referenced objects are loaded. Try the following, and check the output.

function waitForChild(instance, name)
while not instance:FindFirstChild(name) do
instance.ChildAdded:wait()
end
return instance:FindFirstChild(name)
end


if game:GetService("UserInputService").TouchEnabled == false then --(or true)
print("check 1")
waitForChild(script.Player,"PlayerGui")
print("check 2")
waitForChild(script.Player.PlayerGui,"GUI")
print("check 3")
script.Parent.GUI.Visible = true
print("check 4")
end

Report Abuse
wayne2018 is not online. wayne2018
Joined: 04 Jun 2014
Total Posts: 2509
31 Mar 2016 01:14 PM
Bump
Report Abuse
wayne2018 is not online. wayne2018
Joined: 04 Jun 2014
Total Posts: 2509
31 Mar 2016 01:30 PM
@Time that doesn't seem to work.
Report Abuse
wayne2018 is not online. wayne2018
Joined: 04 Jun 2014
Total Posts: 2509
31 Mar 2016 02:38 PM
I tried other ways but it still doesn't work....
Report Abuse
wayne2018 is not online. wayne2018
Joined: 04 Jun 2014
Total Posts: 2509
31 Mar 2016 03:35 PM
...
Report Abuse
wayne2018 is not online. wayne2018
Joined: 04 Jun 2014
Total Posts: 2509
31 Mar 2016 11:28 PM
Someone help?
Report Abuse
Darkenus is not online. Darkenus
Joined: 17 Jul 2014
Total Posts: 1997
31 Mar 2016 11:34 PM
is this a local script or normal script?
and where is this script located?
Report Abuse
wayne2018 is not online. wayne2018
Joined: 04 Jun 2014
Total Posts: 2509
31 Mar 2016 11:36 PM
This is a normal script located in workspace
Report Abuse
Darkenus is not online. Darkenus
Joined: 17 Jul 2014
Total Posts: 1997
31 Mar 2016 11:46 PM
So you want to get the InputService of the server?

The server has no input.

Therefore you NEED to put this in a localscript - somewhere in StarterGui, StarterPack, or StarterPlayerScripts > PlayerScripts.

You're trying to get the input of a PLAYER, not the server.

http://wiki.roblox.com/?title=API:Class/UserInputService

The UserInputService is a service which is used to detect the type of input available on a user's device via the use of a LocalScript. It allows LocalScripts to perform different actions depending on the device used to provide the best experience for the end user. The purpose of this service is primarily to allow for games to work well on both mobile devices and computers.

> LOCALSCRIPT!
Report Abuse
wayne2018 is not online. wayne2018
Joined: 04 Jun 2014
Total Posts: 2509
31 Mar 2016 11:58 PM
I made it a localscript and put it in StarterGui, it's still not working.
Report Abuse
wayne2018 is not online. wayne2018
Joined: 04 Jun 2014
Total Posts: 2509
01 Apr 2016 12:10 AM
I figured it out! It finally works!
Report Abuse
Protoduction is not online. Protoduction
Joined: 27 Jul 2012
Total Posts: 1054
01 Apr 2016 12:46 AM
'a normal script'
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image