So I’ve been trying for the past couple of hours to display the part’s name on a billboard gui, and eventually display stats as health and such, but I can’t seem to figure out how to do it properly.
The main premise is that if a player clicks on a structure, without using a clickdetector, that is theirs in this case parented to a folder name ItemHolder on their plot they would be able to see a billboard gui displaying the name of the part.
return function()
---- Private variables ----
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
local Display = script:WaitForChild("Display")
local Text = Display.Text
---- Loaded Modules ----
local Database = require(ReplicatedStorage.Modules.Data.Infrastructure)
---- Private functions ----
local function GetLocalPlot(player)
for _, Plot in pairs(workspace.Plots:GetChildren()) do
local PlotOwner = Plot:GetAttribute("Owner")
if PlotOwner == player.Name then
return Plot
end
end
end
local function PopulateList(Plot, Table)
for i, Item in pairs(Plot.ItemHolder:GetChildren()) do
table.insert(Table, Item.Name)
end
end
local function Set(Target)
local c_Display = Display:Clone()
c_Display.Parent = Target
c_Display.Adornee = Target
c_Display.Text.Text = Target.Name
end
---- Connections ----
Mouse.Button1Down:Connect(function()
local Plot = GetLocalPlot(Player)
local ContentTable = {}
-- Adds all items to the list
PopulateList(ContentTable, Plot)
-- wip
for i = 1, #ContentTable do
if Mouse.Target.Parent == ContentTable[i] then
Set(Mouse.Target.Parent)
end
end
end)
end