Everytime I duplicate this Booth, I want 5 of them in total but I can’t figure out how to make it work in every single model rather than just one. Should I make a Table that accesses every single Booth model so this way I can make it function when it’s duplicated or are there any other solutions?
– In-game
https://gyazo.com/e16f5763f4d3a58d88db8521640b9812
– Server
local Players = game:GetService("Players")
local ProximityPromptService = game:GetService("ProximityPromptService")
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChatService = game:GetService("Chat")
local ProximityPrompt = Instance.new("ProximityPrompt")
ProximityPrompt.Parent = game.Workspace.Booth.ProxPart -- Here
ProximityPrompt.Enabled = true
ProximityPrompt.HoldDuration = 0.3
ProximityPrompt.ActionText = "Claim Booth"
local SurfaceGui = Instance.new("SurfaceGui")
SurfaceGui.Parent = game.Workspace.Booth.Header -- Here
SurfaceGui.Face = "Back"
SurfaceGui.Enabled = true
local FrameGui = Instance.new("Frame")
FrameGui.Parent = SurfaceGui
FrameGui.Size = UDim2.new(1, 0, 1, 0)
FrameGui.BackgroundTransparency = 1
local TextGui = Instance.new("TextLabel")
TextGui.Parent = FrameGui
TextGui.Size = UDim2.new(1, 0, 1, 0)
TextGui.Font = Enum.Font.FredokaOne
TextGui.BackgroundTransparency = 1
TextGui.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
TextGui.TextColor3 = Color3.fromRGB(255, 255, 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.2, 0)
BillboardGui.StudsOffset = Vector3.new(-1.5, 5, 0)
local BillboardText = Instance.new("TextLabel")
BillboardText.Parent = BillboardGui
BillboardText.Size = UDim2.new(4, 0, 1, 0)
BillboardText.Font = Enum.Font.FredokaOne
BillboardText.TextStrokeTransparency = 0.9
BillboardText.TextColor3 = Color3.fromRGB(255, 255, 255)
BillboardText.Text = "CLAIM BOOTH!"
BillboardText.TextScaled = true
BillboardText.BackgroundTransparency = 1
local tweenInfo = TweenInfo.new(
2.5,
Enum.EasingStyle.Bounce,
Enum.EasingDirection.Out,
-1,
true,
1
)
local Tween = TweenService:Create(BillboardText, tweenInfo, { Size = UDim2.new(3.5, 0, 4, 0) })
Tween:Play()
local RemoteEvent = Instance.new("RemoteEvent")
RemoteEvent.Parent = ReplicatedStorage
RemoteEvent.Name = "BoothEvent"
local Claimed = Instance.new("ObjectValue")
Claimed.Value = nil
local function onPlayerRemoving(player)
if Claimed.Value == player then
Claimed.Value = nil
BillboardText.Text = "Claim Booth!"
BillboardText.TextColor3 = Color3.fromRGB(255, 255, 255)
Tween:Play()
ProximityPrompt.Enabled = true
print("A player has left: " .. player.Name)
end
end
Players.PlayerRemoving:Connect(onPlayerRemoving)
ProximityPrompt.Triggered:Connect(function(player)
if Claimed.Value == nil then
Claimed.Value = player
BillboardText.Text = "Owned by: " .. player.Name
BillboardText.TextColor3 = Color3.fromRGB(203, 203, 203)
Tween:Cancel()
ProximityPrompt.Enabled = false
RemoteEvent:FireClient(player)
end
end)
local RemoteFunction = ReplicatedStorage.RemoteFunction
RemoteFunction.OnServerInvoke = function(player, text)
if Claimed.Value == player then
local FilteredText = ChatService:FilterStringForBroadcast(text, player)
TextGui.Text = FilteredText
return FilteredText
end
end
– Client
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local ChatService = game:GetService("Chat")
local RemoteEvent = game.ReplicatedStorage:WaitForChild("BoothEvent")
local BoothGui = game.StarterGui.BoothGui
local LocalPlayer = Players.LocalPlayer
local PlayerBoothGui = LocalPlayer.PlayerGui:WaitForChild("BoothGui")
RemoteEvent.OnClientEvent:Connect(function()
PlayerBoothGui.Enabled = true
PlayerBoothGui.Frame.BackgroundTransparency = 0
end)
local CloseButton = PlayerBoothGui.Frame.CloseButton
CloseButton.MouseButton1Click:Connect(function()
if PlayerBoothGui.Enabled == true then
PlayerBoothGui.Enabled = false
end
end)
local SubmitButton = PlayerBoothGui.Frame.SubmitButton
local RemoteFunction = ReplicatedStorage.RemoteFunction
local Textbox = PlayerBoothGui.Frame.Frame.TextBox
SubmitButton.MouseButton1Click:Connect(function()
local filteredName = RemoteFunction:InvokeServer(Textbox.Text)
Textbox.Text = filteredName
PlayerBoothGui.Enabled = false
end)
What can I do here to make it apply to every single Booth I duplicate?
Any help is appreciated!