-- LocalScript (placed in StarterPlayerScripts)
local player = game.Players.LocalPlayer -- Get the local player
local frameEvent = game.ReplicatedStorage:WaitForChild("FrameEvent")
local frameIndex = 1
-- Retrieve frames dynamically
local function getFrames()
local frames = {}
local playerGui = player:WaitForChild("PlayerGui") -- Ensure PlayerGui exists
local pointGui = playerGui:WaitForChild("PointGui") -- Ensure PointGui exists
local aFolder = pointGui:WaitForChild("A") -- Ensure A folder exists
for i = 1, 6 do
local frame = aFolder:FindFirstChild("A" .. i)
if frame then
table.insert(frames, frame)
else
warn("Frame A" .. i .. " not found!")
end
end
return frames
end
-- Function to update AText background color based on the player's team
local function updateATextBackgroundColor()
local playerGui = player:WaitForChild("PlayerGui") -- Ensure PlayerGui exists
local pointGui = playerGui:WaitForChild("PointGui") -- Ensure PointGui exists
local aFolder = pointGui:WaitForChild("A") -- Ensure A folder exists
local aText = aFolder:FindFirstChild("AText") -- Find the AText button
-- Directly set background color based on player's team
if aText then
if player.Team and player.Team.Name == "Sanders" then
aText.BackgroundColor3 = Color3.fromRGB(255, 255, 0) -- Yellow
print("Set AText background color to Yellow (Sanders team)")
elseif player.Team and player.Team.Name == "Bluemans" then
aText.BackgroundColor3 = Color3.fromRGB(0, 0, 255) -- Blue
print("Set AText background color to Blue (Bluemans team)")
end
else
warn("AText not found!")
end
end
local frames = getFrames()
-- Listen for the event from the server to update frames
frameEvent.OnClientEvent:Connect(function()
if frameIndex <= #frames then
local frame = frames[frameIndex]
frame.BackgroundColor3 = Color3.fromRGB(255, 255, 0) -- Change color to
Yellow
frame.Visible = true -- Make it visible
print("Updated frame " .. frame.Name .. " to Yellow")
frameIndex = frameIndex + 1 -- Move to the next frame
else
print("All frames have been processed.")
-- Update the AText background color after all frames are processed
updateATextBackgroundColor()
end
end)