Basically think in a map selector, then when you click the map then it changes the map image and the map name (that worked), but when you click the button it changes its color, but when you select another button, it changes the color of this button and set the one you before clicked to normal
I had another code that almost worked but when clicking a third button for example the buttons changed to the name of the button and everything bugged out, neither me understood what happened
but this is what i tried so far
for i, button in pairs(script.Parent:GetChildren()) do
if button:IsA("ImageButton") then
local repStorage = game:GetService("ReplicatedStorage")
local screenGui = script.Parent.Parent
local mapImage = screenGui.MapHolder.MapImage
local mapName = screenGui.MapHolder.MapNameHolder.MapName
local text = button:WaitForChild("Text")
button.MouseButton1Click:Connect(function()
local formerButton = button
local clone = button:Clone()
local cloneText = clone:WaitForChild("Text")
clone.Parent = script.Parent
clone.ImageTransparency = 0
cloneText.BackgroundColor3 = Color3.fromRGB(255,100,0)
cloneText.TextColor3 = Color3.fromRGB(0,0,0)
clone.MouseLeave:Connect(function()
clone.ImageTransparency = 0
cloneText.BackgroundColor3 = Color3.fromRGB(255,100,0)
cloneText.TextColor3 = Color3.fromRGB(0,0,0)
end)
button.Parent = repStorage
mapName.Text = text.Text
mapName.AutomaticSize = Enum.AutomaticSize.None
mapName.Size = UDim2.new(0.089,0,0.8,0)
mapName.AutomaticSize = Enum.AutomaticSize.X
mapName.Size = mapName.Size + UDim2.new(0.02,0,0,0)
end)
end
end
it works but when clicking another button the button you clicked before stays “selected”, I scripted this alone without tutorials and im willing to learn something, any help im glad!