OOOOOOOOF, I meant to make it so when I click on one of the flags, it’ll change them to the flags country color. i.e, UK, USA, etc. Sorry for not explaining that.
local flagsFolder = game.Workspace:WaitForChild("FlagsFolder")
for _, v in pairs (flagsFolder:GetChildren()) do
v.ClickDetector.MouseClick:Connect(function(Player)
if Player.TeamColor ~= v.BrickColor then
if game.Teams:FindFirstChild(v.Name) then
local selectedTeam = game.Teams:WaitForChild(v.Name)
Player.Team = selectedTeam
end
else
print("The player is already in the selected team.")
end
end)
end
local Frame = script.Parent
for Index, Item in pairs (Frame:GetChildren()) do
if Item.ClassName == "TextButton" then
Item.MouseButton1Click:Connect(function()
if Item.Name == "USA" then
game.ReplicatedStorage.RemoteEvent:FireServer("USA")
elseif Item.Name == "UK" then
game.ReplicatedStorage.RemoteEvent:FireServer("UK")
end
end)
end
end
Script:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player, SelectedTeam)
if SelectedTeam == "USA" then
Player.TeamColor = BrickColor.new("Persimmon")
elseif SelectedTeam == "UK" then
Player.TeamColor = BrickColor.new("Bright blue")
end
end)
It’s sadly not working, I do believe I’ve done everything you did. I made sure it was getting the “ImageButton” not “TextButton”.
Here’s a image of my explorer and my script.
LocalScript: (ignore the ones in the buttons)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remote = ReplicatedStorage.ServerEvents.Team
for i, v in pairs(script.Parent:GetChildren()) do
if v.ClassName == "ImageButton" then
v.MouseButton1Click:Connect(function()
if v.Name == "ContinentalArmy" then
remote:FireServer("Continental Army")
elseif v.Name == "GreatBritain" then
remote:FireServer("Great Britain")
end
end)
end
end
RemoteHandler Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerEvents = ReplicatedStorage.ServerEvents
ServerEvents.Team.OnServerEvent:Connect(function(player, selectedTeam)
if selectedTeam == "Continental Army" then
player.TeamColor = BrickColor.new("Bright blue")
elseif selectedTeam == "Great Britain" then
player.TeamColor = BrickColor.new("Bright red")
end
end)