Detecting who owns the VIP Server and giving them a GUI

Recently (like an hour ago lol) I figured out how to detect if the current server is a VIP Server.

This opened up some amazing opportunities which will suit my game. However I have ran into a problem. I don’t know how to detect who is the owner of the VIP Server and to give them a GUI.

Basically, I want ONLY the VIP Server OWNER to have a gui, let’s call this “KickGUI” for the time being. The VIP Server owner will receive this GUI, whereas the other players cannot hold this amazing GUI.

Lol sorry for being dramatic, but anyway I could achieve this?

Thanks, Carl the Plandog

9 Likes

Looks to be a localscript, going to guess inside StarterGui or the GUI in which the VIP Server Owner will receive?

I would put it in StarterGUI, but you could put it in the GUI

image image image

lol help

2 Likes

this is simply solved:

-- server script
local RemoteEvent = -- your event

game.Players.PlayerAdded:Connect(function(plr) -- activated on player join
    if plr.UserId == game.PrivateServerOwnerId then -- is the player the vip server owner?
        RemoteEvent:FireClient(plr) -- gives them a gui
    end
end)

-- local script
local RemoteEvent = -- your event

RemoteEvent.OnClientEvent:Connect(function() -- remote recieve function
    local GUIClone = game:GetService("ReplicatedStorage"):WaitForChild("KickGui"):Clone() -- gui clone
    GUIClone.Parent = game.Players.LocalPlayer.PlayerGui -- gui parenting
end)

just make sure the gui is moved to replicated storage as a local script can’t access serverstorage

6 Likes

You spelled function wrong in

made me spend around 5 minutes trying to find the error

it should be :FireClient not .FireClient as well

After sorting this out I now get a new error which says “unable to cast value to object”. Any ideas?

1 Like

show your code with lines and the error refering to which lineif it helps. also thanks for saying i updated it correctly now. just some small typing flaws

1 Like

I already have. GUI is made and already placed into the RS

That was the first thing I did

Could you send a place file of what you currently have? It’ll be much easier to fine tune it that way.

did you move the GUI to replicated storage as stated instead of serverstorage?

For the 3rd time YES I have,…

then i still need a codeline from where this error refers to as you didn’t provide that yet

Helppl0x.rbxl (22.4 KB)

your fireclient is missing the plr.UserId paremeter

edit
i made a small mistake you shouldn’t take the userid you should take the player
[Fixed the code post]

Specifically addressing the above error, :FireClient() expects a player instance to be passed as the first argument. :FireClient(instance Player, ...).

Addressing the proposed solutions above, I believe this is redundant. There will be a slight delay because of networking between the server and client, and it does not in itself prevent a malicious client from gaining access to your GUI.

Hide/show the GUI on the client if the user is the VIP server owner (you were doing this before, however you tried to access a descendant of ServerScriptService from the client which is not replicated to the client), and perform the necessary sanity checks server-side when performing actions (e.g. validate the vip owner performed the action). Like so:

-- Pseudocode
Event.OnServerEvent:Connect(function(Player, Type, Target)

    if Player.UserId == game.PrivateServerOwnerId then -- Validates that the player who is performing the action is the vip server owner.
        -- Perform action.
    end

end)

Edit: PrivateServerOwnerId isn’t replicated to the client, which is strange. I’ll be making a feature request for this. Thanks @VoidedBIade.

you cant check privateserverownerid on the client thus the reason its checked on the server and the gui given on the client. unless it gets set on the client too

1 Like

Yeah can anyone apply these changes for me lol

i already applied everything with some edits here
just copy and paste it nothing hard about it

I meant in the place…