Hello @leaderdevelopers, the sample code you provided requires a little bit of revisiting, and we’ll discuss those to fix the functionality step by step.
To begin with, its syntax is inaccurate, so it cannot be interpreted. I refurbished the script for what you wanted it to do.
local path1, path2 = "Path to 'MainScoreboard'", "Path to 'UCLScoreboard'"
if args[1] ~= "UCL" then
path1.Visible = false
path2.Visible = true
end
While the code above may not work, I tried to rewrite it as meaningful as the original code was intended for.
First off, typeof, which is a global built-in function, returns Roblox-rebuilt types as a string. These types comprise Axes, Vector3, Instance, etc. (not to be confused with type) Neither of the functions will correspond to what you want, to be checked as the condition. You can use the equals operator, e.g. args[1] ~= "UCL"
if args[1]
is a string. UCL is not considered a specific type but rather a string.
Second, the paths were totally wrong, referring to objects located in the StarterGui service. Improve your knowledge; objects in StarterGui get replicated to PlayerGui of each player that joins the server. The original script did so it was changing the properties of soon-to-be-replicated objects, meaning players wouldn’t see their UI getting visible. What you need to do is determine the right paths to the objects that players are bound to see. For example, a LocalScript as a child of the object would interpret this line: script.Parent.Visible = false
, or a LocalScript which is under PlayerScripts would do
local PlayerGui = script:FindFirstAncestorOfClass("Player").PlayerGui PlayerGui.Gui.Board.Visible = false
Third and final, the phrase false and game.StarterGui.Start.UCLScoreboard.Visible ~= true
is misleading. The keyword and is used in conditional phrases but not in assignments in general. And is simply the and gate, expecting both of the values evaluate to true. However in the code, it’s meant to carry out different tasks. The interpreter thinks the phrase created using the and keyword would be used for type assignment as the Visible property expects a boolean. Briefly, and should not be used here.
You gotta define the paths to objects (path1, path2) in the new script.
For further info and analytical thinking, please navigate to Roblox Documentation. Ensure to get the most out of scripting there!