So, I’ve been trying to use Adonis to change the level of admin once a new value is set to a hosting queue in Workspace. It does the function correctly, but I get errors when I try to use server.Admin:SetLevel(). It’s supposed to change the level of admin to CurrentHost, instead it’s erroring out.
Here is the code I’ve been using:
SERVER PLUGINS' NAMES MUST START WITH "Server: "
CLIENT PLUGINS' NAMES MUST START WITH "Client: "
Plugins have full access to the server/client tables and most variables.
You can use the MakePluginEvent to use the script instead of setting up an event.
PlayerChatted will get chats from the custom chat and nil players.
PlayerJoined will fire after the player finishes initial loading
CharacterAdded will also fire after the player is loaded, it does not use the CharacterAdded event.
service.HookEvent('PlayerChatted',function(msg,plr)
print(msg..' from '..plr.Name..' Example Plugin')
end)
service.HookEvent('PlayerJoined',function(p)
print(p.Name..' Joined! Example Plugin')
end)
service.HookEvent('CharacterAdded',function(plr)
server.RunCommand('name',plr.Name,'BobTest Example Plugin')
end)
--]]
server = nil -- Mutes warnings about unknown globals
service = nil
return function()
print("module loaded")
game.Workspace["testing hosting queue: the first installment"].SurfaceGui.Frame.body.current.Changed:Connect(function()
print("something changed")
if game.Workspace["testing hosting queue: the first installment"].SurfaceGui.Frame.body.current.Text ~= "#PLAYER" then
local username = game.Workspace["testing hosting queue: the first installment"].SurfaceGui.Frame.body.current.Text
local player = game.Players:GetPlayerFromCharacter(game.Workspace[username])
print(username)
print(player.Name)
server.Admin:SetLevel(player, "CurrentHost")
else
print("cannot change admin level of nothing")
end
end)
end
The server can’t access any GUI components, they are accessible only to the clients. You can either use some remote events or consider finding out a way so that the server never has to communicate with the client and the client thus can’t affect what the server does.
He might set the text for the surfacegui in some other script.
As for the error, I looked through Adonis’ script and the line that errored is: data.Groups = service.GroupService:GetGroupsAsync(p.UserId) or {}
Specfically, GetGroupsAsync. What do your prints show?
This isn’t the issue, and SurfaceGui is in the server itself. It should be able to access it because it can read the player’s username from it just fine.
If the server attempts to change a GUI it would fail since the UI simply doesn’t exist on the server. As for the text changing part, if a client is to change the text of the UI locally, the change will not carry to all client and neither the server (again, the server can’t access the children)
That is false. Server can change UI, it’s not recommended. He’s using a surface gui, so it’s a good chance he’s changing the text on the server. Either way, that’s not the issue. His script detects the surface GUI change perfectly fine.
@Golembyte
This is a long shot, but could you try doing print(typeof(player)) under your other prints?
I think you may be getting mixed up with ScreenGui, but SurfaceGui is different. I am pretty sure that while it is is workspace, the server can edit it.
Replace server.Admin:SetLevel(player, "CurrentHost") with server.Admin.SetLevel(player, "CurrentHost")
Line 139 runs GroupService:GetGroupsAsync(player.UserId), but it’s saying that the UserId is nil. This wouldn’t be possible with a normal player object, so you’re passing a table somehow and that’s the only way I can see the script passing a table.
I don’t know how you would do this with Adonis, you may be better off handling that inside the modulescript. I don’t have any experience with Adonis. You should probably make a new question that way you can explain the issue.