So I have two GUI labels that show the leaderstats for mobile players. However, my script that detects if the player is on mobile or not doesn’t seem to be working.
local UserInputService = game:WaitForChild("UserInputService")
local IsMobile = UserInputService.TouchEnabled
local IsConsole = UserInputService.GamepadEnabled
local IsComputer = UserInputService.KeyboardEnabled
local Player = game.Players.LocalPlayer
local leaderstats = Player:WaitForChild("leaderstats")
local Time = leaderstats:WaitForChild("Time")
local Age = leaderstats:WaitForChild("Age")
local TimeLabel = script.Parent:WaitForChild("Time")
local AgeLabel = script.Parent:WaitForChild("Age")
repeat task.wait() until game:IsLoaded()
while task.wait(1) do
TimeLabel.Text = "Time: " .. Time.Value
AgeLabel.Text = "Age: " .. Age.Value
end
if IsMobile == true then
TimeLabel.Visible = true
AgeLabel.Visible = true
elseif IsComputer then
TimeLabel.Visible = false
AgeLabel.Visible = false
elseif IsConsole then
TimeLabel.Visible = false
AgeLabel.Visible = false
end
If you think you know what went wrong, please let me know. Thank you and have a wonderful day!
I think I fixed it! The script wasn’t getting past the while task.wait() loop, so I moved it to the bottom of the script and it worked! Thanks for the help, though!