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?
-- 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
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
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