Well. I’m trying to make a GUI visible for a player or a group rank. How can I do this?
I’ve tried this:
if plr.Name == "Welliux" then
game.StarterGui.ScreenGui.Frame.Visible = true
end
How can I make this actually work?
Well. I’m trying to make a GUI visible for a player or a group rank. How can I do this?
I’ve tried this:
if plr.Name == "Welliux" then
game.StarterGui.ScreenGui.Frame.Visible = true
end
How can I make this actually work?
You need to make the GUI instance visible for the player:
Try this code:
if plr.Name == "Welliux" then
plr.PlayerGui.ScreenGui.Frame.Visible = true
end
What type of script is it? (Local or global)
Local (just filling out characters)
I suggest using userid instead plr.Name. Also, I assume that this is a local script (correct me if neccesary).
No, It’s a normal script. And I’ll put userId instead
I was having the same issue yesterday only I was doing it with group rank. It worked when I used the script inside a normal script in serverscriptstorage.
local button = game.StarterGui.ScreenGui.TextButton
game.Players.PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup(MyGroupId) >= 160 then
button.Visible = true
else
button.Visible = false
end
end)
I’ve gotten it in ServerScriptStorage. But It won’t work.
Script rn:
if plr.UserId == "125183183" then
plr.PlayerGui.ScreenGui.Frame.Visible = true
end
Don’t use a strings to call for the actual user’s id. Remove the strings.
Maybe try using this script. It will make sure that everyone except you will have it automatically hidden.
game.Players.PlayerAdded:Connect(function(plr)
if plr.Name == "Welliux" then
game.StarterGui.ScreenGui.Frame.Visible = true
else
game.StarterGui.ScreenGui.Frame.Visible = false
end
end)
Using this thread;
Get Role In Group
We can get an understanding on how to make a system like this.
The example code in there is;
game.Players.PlayerAdded:Connect(function(player)
print("Player is ranked as '" .. player:GetRoleInGroup(2) .. "' in group, 'LOL'!")
end)
Now lets use what they provided to make our own!
local groupID = 2 --Left as an example, make it yours.
local rolename = "Example" -- left as an example, make it yours.
game.Players.PlayerAdded:Connect(function(plr)
--your script
local role = plr:GetRoleInGroup(groupID)
if role == rolename then
print(plr.Name.." is the role")
local GUI = script.GUI:Clone() -- Make sure to make this in a server script, none should be client side as this can be exploited.
GUI.Parent = plr.PlayerGui
else
--they are not that role!
end
end)
That is for the group role, now lets do a player name. I do not recommend having this local, it should be in serverscriptservice and set up this way;
I also do not recommend doing a if plr.Name statement, lets think security, a person can exploit this and get access to the GUI. Here is what I recommend doing;
local userIDs = {311040474,1} --Left as an example, you can put as many as you want.
game.Players.PlayerAdded:Connect(function(plr)
--your script
for _,v in pairs(userIDs) do
if plr.UserId == v then
print(plr.Name.." has the specified UserID")
local GUI = script.GUI:Clone() -- Make sure to make this in a server script, none should be client side as this can be exploited.
GUI.Parent = plr.PlayerGui
else
--they do not have access
end
end
end)
The solution @Random_User54 provided is a local script, and highly exploitable. I highly recommend using what I’ve provided for security purposes. Hope I helped!
How? If the script is server-sided, an exploiter can’t change the name of their player. The player instance is created on the server. Exploiters can’t tamper with this at all, the real question is of practice. Usernames can change while UserIds are permanently associated with an account and unchanging.