#Make index text box green when item found
1 messages · Page 1 of 1 (latest)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage:WaitForChild("CelebFoundEvent")
local player = game.Players.LocalPlayer
local frame = script.Parent:WaitForChild("Frame")
-- When player joins, check FoundCelebs to pre-fill GUI
local function updateIndex()
local foundCelebs = player:WaitForChild("FoundCelebs")
for _, celebFlag in ipairs(foundCelebs:GetChildren()) do
local label = frame:FindFirstChild(celebFlag.Name)
if label and label:IsA("TextLabel") then
label.TextColor3 = Color3.fromRGB(0, 255, 0)
end
end
-- Watch for any new finds added later
foundCelebs.ChildAdded:Connect(function(child)
local label = frame:FindFirstChild(child.Name)
if label and label:IsA("TextLabel") then
label.TextColor3 = Color3.fromRGB(0, 255, 0)
end
end)
end
updateIndex()
-- Update immediately when event fires
event.OnClientEvent:Connect(function(celebName)
local label = frame:FindFirstChild(celebName)
if label and label:IsA("TextLabel") then
label.TextColor3 = Color3.fromRGB(0, 255, 0)
end
end)print("Hello world!")