How do I send a UI over that I want only the server to originally have?

Right now, I have a UI in ServerStorage. I’m basically trying to get it directly to a specific player without giving other players/the receiver a chance to copy the ui and give it to themselves, as it’s part of a gamepass. The problem with this is that if you send anything over a remote event, the receiving side will look for it’s physical copy. But the thing is, the item is in ServerStorage. If I create a clone, there’s no Parent by default, and I’d have to set one, although I read here that assigning ui parents through the server should not be done. Is there any way to do this without the chance of another player tampering/taking this data?

Server module script:

ReplicatedStorage:WaitForChild("GivePassRewards"):FireClient(player,"Radio",passItems.RadioGui)

Local script:

givePassRewardsEvent.OnClientEvent:Connect(function(passName,item)
	print(passName,item)
	if passName == "Radio" then
		local uiContents = item:Clone()
		uiContents.RadioButton.Parent = sideButtonsGui.BoundingFrame
		uiContents.Parent = player.PlayerGui
	end
end)

I’ll be gone for a while, but I’ll respond to replies as soon as I can.

Without large input delay/ lag, there isn’t exactly a way to stop somebody from taking the UI. However, this doesn’t mean you can’t stop people from using the UI without permisison.

You may be forced to give the player the UI on the client, but you can do checks (as you should with all your code) on the server, as to make sure the player can use it. You may do this without realising it, i.e. a debounce would be a form of a check. One of the checks you could do is see if the player has the gamepass, and if they don’t either kick them or just do nothing.

3 Likes

Yes, your radio’s remote event (I assume you have one somewhere) should have validate that the player has the gamepass on the server. As long as you have that check then there’s no need to discreetly pass the UI to the client. You can leave the GUI disabled/invisible on their client unless they have the gamepass. Kick them if you want if they fire the event but don’t own the gamepass.

1 Like

Alright, thanks for the suggestions! I’ll leave a quick code for people coming here in the future for what this would sort of look like, in a playeradded event in a server script (I haven’t tested this, but it should be fine. Formatting is weird because I made it here):

player.PlayerGui.ChildAdded:Connect(function(child)
if child.Name == "RadioUi" then
local owned = MarketplaceService:UserOwnsGamepassAsync(player.UserId,(id))
if not owned then
player:Kick()
end
end
end

EDIT: This would require a remote event to fire from the client, as no ui changes are replicated to the client, so the server won’t see this.