What am I doing wrong for this script?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I am trying to achieve this script that shows a button or a text label if a player is on mobile or pc.

  2. What is the issue? Nothing appears in the output and the BillboardGui is not appearing.

BillboardGui

  1. What solutions have you tried so far? Nothing lol, I think the DevForum will be a better choice.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local Teams = game:GetService("Teams")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")

if Player.TeamColor == BrickColor.new('Electric blue') then
	print("Player is a Cop")
	script.Parent.Enabled = false
elseif Player.TeamColor == BrickColor.new('Really red') or Player.TeamColor == BrickColor.new('Lily white') then
	print("Player is a Criminal or Citizen")
	if UIS.TouchEnabled and not UIS.KeyboardEnabled and not UIS.MouseEnabled
		and not UIS.GamepadEnabled and not GuiService:IsTenFootInterface() then
		print("Player is on Mobile")
		script.Parent.Enabled = true
		script.Parent.TextButton.Visible = true
		script.Parent.Text.Visible = false
	elseif not UIS.TouchEnabled and UIS.KeyboardEnabled and UIS.MouseEnabled
		and not UIS.GamepadEnabled and not GuiService:IsTenFootInterface() then
		print("Player is on PC")
		script.Parent.Enabled = true
		script.Parent.TextButton.Visible = false
		script.Parent.Text.Visible = true
	else
		print("Nil")
	end
end
1 Like

If nothing is appearing in the output, that means that the conditions for both the if and elseif are false, so the team color isn’t electric blue, really red, or lily white.

UIS.TouchEnabled, UIS.KeyboardEnabled, UIS.MouseEnabled, UIS.GamepadEnabled are all booleans, meaning that it should be:

elseif UIS.TouchEnabled == false then
-- Code here
end

Where did you get this from? In the case of booleans not a is more clearer and shorter to read than a == false.

1 Like

I got this from developer.roblox.com

If all are false it will print (“Nil”) Will it not?

I will try it although is kinda more confusing

Nah, it wouldn’t print Nil if the player isn’t in any of the teams, because the print nil is part of the if statement inside of the first elseif. if the player isn’t on Electric Blue, then it’ll check if they’re on Really red or Lily White. If the player is also not on either of those teams, the game won’t go through the second if statement because it’s in the first elseif.

Oh okay thank you explain learn something new today :smiley:

Found problem, shouldn’t have used BrickColor.new