im trying to get it so that the script shows a button stored in serverstorage, i found a way but it only works once, once the player dies it dissapears.
i tried this but it wont work either
local Players = game:GetService("Players")
local GroupId = 32577708
local function ShowMenu(char)
game:GetService("ServerStorage"):WaitForChild("AdminButton"):Clone().Parent = Players:GetPlayerFromCharacter(char).PlayerGui.ScreenGui
end
Players.PlayerAdded:Connect(function(Player)
print(Player:GetRoleInGroup(GroupId))
if(Player:GetRoleInGroup(GroupId) == "Admin" or Player:GetRoleInGroup(GroupId) == "Owner") then
Player.CharacterAdded:Connect(ShowMenu)
end
end)
edit: what i mean by it does not work is that it literally does not show anything up.
You should switch the order in which you connect the events. First use .CharacterAdded then check if they have the appropriate role. The delay in time when the server checks if they are the proper role doesn’t properly connect the event on startup.
Try making it so that it becomes visible instead of cloning it. You can then put the GUI in StarterGUI instead of ServerStorage. You’ll have to make sure the GUI’s visibility is disabled by default, though.
Got it, ill try that tommorow as its 2 am for me right now.
but what if some exploiter just makes it visible and messes with the admin panel in my game
I don’t really know how you’ll deal with that, I’m not much of a scripter myself. Unless your game is popular, that shouldn’t happen, so you shouldn’t have much to worry about.
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Char)
if (Player:GetRoleInGroup(GroupId) == "Admin" or Player:GetRoleInGroup(GroupId) == "Owner") then
ShowMenu(Char)
end
end)
end)
That would work but it would be better if you passed player directly. Additionally, add WaitForChild when getting the player gui because it takes a second to load I think.
local Players = game:GetService("Players")
local GroupId = 32577708
local function ShowMenu(char)
game:GetService("ServerStorage"):WaitForChild("AdminButton"):Clone().Parent = Players:GetPlayerFromCharacter(char):WaitForChild("PlayerGui"):WaitForChild("ScreenGui")
end
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Char)
if (Player:GetRoleInGroup(GroupId) == "Admin" or Player:GetRoleInGroup(GroupId) == "Owner") then
ShowMenu(Char)
end
end)
end)
local Players = game:GetService("Players")
local GroupId = 32577708
local function ShowMenu(Player)
local button = game:GetService("ServerStorage"):WaitForChild("AdminButton"):Clone()
button.Parent = player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui")
button.Parent.ResetOnSpawn = false
end
Players.PlayerAdded:Connect(function(Player)
if (Player:GetRoleInGroup(GroupId) == "Admin" or Player:GetRoleInGroup(GroupId) == "Owner") then
ShowMenu(Player)
end
end)