How can I make a Pop Up UI for a Player when they claim a Booth

You can write your topic however you want, but you need to answer these questions:

Basically I made a Booth where a Player can claim it and from there they’d have the ability to change the text of the header that’s located on the booth plain and simple.

  1. I’m creating all the UI’s via Script I just think it’s much better can be edited easily & keeps everything organized.

  2. Via Server if a Player claims a Booth and the UI pops up would that mean it’d pop up for everyone in the server?

  3. How do I give the Player the ability to change the text on the Booth part from the UI.

  4. If a Player has the ability to change text on the part via UI, does that mean I’d have to somehow put security checks on the words that they are typing or does Roblox do that manually?

Main issue is I just can’t figure it out and my brain is :exploding_head: any help would really appreciated! I’ll post the code below for a better idea of what I did (btw this is my 2nd week of programming using lua i probs know my code bad dont roast :frowning: )

-- local Players = game:GetService("Players")
local ProximityPromptService = game:GetService("ProximityPromptService")
local TweenService = game:GetService("TweenService")


local ProximityPrompt = Instance.new("ProximityPrompt")
ProximityPrompt.Parent = game.Workspace.Booth.ProxPart
ProximityPrompt.Enabled = true
ProximityPrompt.HoldDuration = 0.3
ProximityPrompt.ActionText = "Claim Booth"

local SurfaceGui = Instance.new("SurfaceGui")
SurfaceGui.Parent = game.Workspace.Booth.Header
SurfaceGui.Face = "Back"

local FrameGui = Instance.new("Frame")
FrameGui.Parent = SurfaceGui
FrameGui.Size = UDim2.new(1, 0, 1, 0)
FrameGui.BackgroundColor3 = Color3.fromRGB(39, 39, 39)

local TextGui = Instance.new("TextLabel")
TextGui.Parent = FrameGui
TextGui.Size = UDim2.new(1, 0, 1, 0)
TextGui.Font = Enum.Font.FredokaOne
TextGui.BackgroundTransparency = ""
TextGui.TextColor3 = Color3.fromRGB(84, 138, 255)
TextGui.Text = "Empty"
TextGui.TextScaled = true

local BillboardGui = Instance.new("BillboardGui")
BillboardGui.Parent = game.Workspace.Booth.Header
BillboardGui.Size = UDim2.new(1, 0, 1, 0)
BillboardGui.StudsOffset = Vector3.new(-1.5, 5, 0)

local TextGui2 = Instance.new("TextLabel")
TextGui2.Parent = BillboardGui
TextGui2.Size = UDim2.new(4, 0, 1, 0)
TextGui2.Font = Enum.Font.FredokaOne
TextGui2.TextStrokeTransparency = 0.9
TextGui2.TextColor3 = Color3.fromRGB(255, 255, 255)
TextGui2.Text = "Claim Booth!"
TextGui2.TextScaled = true
TextGui2.BackgroundTransparency = 1

local ScreenGui2 = Instance.new("ScreenGui")
ScreenGui2.Parent = game.StarterGui
ScreenGui2.Enabled = false

local Frame = Instance.new("Frame")
Frame.Parent = ScreenGui2
Frame.Active = true
Frame.Size = UDim2.new(0.5, 0, 0.5, 0)
Frame.BackgroundColor3 = Color3.fromRGB(255, 161, 124)

local tweenInfo = TweenInfo.new(
	2.5, 
	Enum.EasingStyle.Elastic, 
	Enum.EasingDirection.Out, 
	-1,  
	true, 
	3 
)
local Tween = TweenService:Create(TextGui2, tweenInfo, { Size = UDim2.new(3.5, 0, 4, 0) })

Tween:Play()

local CheckUser = Players.PlayerRemoving
local Claimed = Instance.new("ObjectValue")
Claimed.Value = nil

ProximityPrompt.Triggered:Connect(function(player)
	
	if Claimed.Value == nil then
		Claimed.Value = player
		TextGui2.Text = "Owned by:  " .. player.Name
		TextGui2.TextColor3 = Color3.fromRGB(255, 255, 255)
		Tween:Cancel()
			
		-- Displaying User Interface Pop Up if Booth is Claimed by a Player.
		if Claimed.Value == player then
			
		end
			
			local function onPlayerRemoving(player)
				Claimed.Value = nil
				TextGui2.Text = "Claim Booth!"
				TextGui2.TextColor3 = Color3.fromRGB(255, 255, 255)
				Tween:Play()
				print("A player has left:  " .. player.Name)
			end

			Players.PlayerRemoving:Connect(onPlayerRemoving)
	end
end)
print("Booth Successful")

GUIs are client objects and thus the client should be responsible for everything GUI-related. You should have the server tell the client to create the GUI via a remote event. Even better, have the GUI already made and just toggle its visibility on command.

1 Like

No, not necessarily. If you reference player.PlayerGui you can change only one player’s GUI, as opposed to all of them. Just as a note, everything you put in StarterGui can be accessed in PlayerGui, so you don’t have to worry about only instancing things to PlayerGui.

More in-depth explaination

Essentially, StarterGui will replicate changes to the server unless you use local scripts inside the GUI. PlayerGui will only replicate to the player’s screen, so you can change things inside of it using Server scripts(such as adding/removing UI, making it visible, ETC), without having the entire server see.
More info can be found here: Roblox Classes: PlayerGui

I’d make a GUI with a TextBox input, and then when they hit a certain button(such as a submit button), it would fire a RemoteEvent where the server would set the text of the booth’s surfaceGUI.

You would have to check the text by using :FilterStringForBroadcast. Fairly simple if you use a RemoteEvent:

--Example code XD 

local Chat = game:GetService("Chat") --Get chatService
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, text) --Text would be the text from whatever TextBox you use
	Chat:FilterStringForBroadcast(text, player) --:FilterStringForBroadcast() uses two arguments, the first one being the text you want to filter, and the second one being the player who sent it
	--Write code/put your code here that would update the booth's sufaceGUI
end)
2 Likes

How do I reference player.PlayerGui do you have an example of it can be done? Thank you.

I’ve never really used Remove Events, so I have no idea how I can get the server to tell the client to create the GUI via Remote Event if you have any examples or links to documentations would be great :smiley:

Looks like RemoteEvents are pretty useful if only I knew how to fire a RemoteEvent would be great haha.

Okay yeah that makes a lot of sense I see now, at the start I thought it was gonna be pretty complicated having to filter the text from every possible bad word :rofl:

1 Like

Quite simply, you just would put your player reference and then the .PlayerGui and your path. Such as: player.PlayerGui.ExampleGui instead of game.StarterGui.ExampleGui.

Here is a video I found on it, I can also link you to the official documentation if you’d like.