PlayersHouse, PlayersHouses = CheckHouses:InvokeServer()
for i, v in pairs(Frame:GetChildren()) do
if v:IsA('ImageButton') then
if Price.Text == 'SELECT' then
if v.Name == PlayersHouse then
v.Bottom.Price.Text = 'SELECTED'
v.Bottom.Price.TextColor3 = Color3.fromRGB(255, 255, 255)
else
v.Bottom.Price.Text = 'SELECT'
v.Bottom.Price.TextColor3 = Color3.fromRGB(255, 255, 255)
end
end
end
end
This If statement says âonly do the following stuff if Price.Text already says SELECTâ.
So yes, the button that says SELECTED will fail that check and will not do any of things inside the scope of this If statement. The only place you change the value assigned to .Text is nested inside that parent If statement, so it will never change.
Not clear on the context or reason for the following check:
if v.Name == PlayersHouse then
as this doesnât appear to add value at this point in the code. Consider removing this line and one corresponding âendâ?
Your loops are nested wrong, so it only changes the text of anything named SELECT.
Here is how it should be written.
for i, v in pairs(Frame:GetChildren()) do
if v:IsA('ImageButton') then
if Price.Text == 'SELECT' then
if v.Name == PlayersHouse then
v.Bottom.Price.Text = 'SELECTED'
v.Bottom.Price.TextColor3 = Color3.fromRGB(255, 255, 255)
end
else
v.Bottom.Price.Text = 'SELECT'
v.Bottom.Price.TextColor3 = Color3.fromRGB(255, 255, 255)
end
end
end
end
Basically, if v.Name == PlayersHouse checks if the button is the players current selected house, and thus changes the Price to be Selected (as thatâs the players selected houe)
for i, v in pairs(Frame:GetChildren()) do
if v:IsA('ImageButton') then
if Price.Text == 'SELECT' then
if v.Name == PlayersHouse then
v.Bottom.Price.Text = 'SELECTED'
v.Bottom.Price.TextColor3 = Color3.fromRGB(255, 255, 255)
end
else
v.Bottom.Price.Text = 'SELECT'
v.Bottom.Price.TextColor3 = Color3.fromRGB(255, 255, 255)
end
end
end
Edit: Sorry about the formatting, canât seem to tab on PC.
for i, v in pairs(Frame:GetChildren()) do
if v:IsA('ImageButton') then
if Price.Text == 'SELECT' then
if v.Name == PlayersHouse then
Price.Text = 'SELECTED'
Price.TextColor3 = Color3.fromRGB(255, 255, 255)
end
elseif Price.Text == 'SELECTED' then
Price.Text = 'SELECT'
Price.TextColor3 = Color3.fromRGB(255, 255, 255)
end
end
end
for i, v in pairs(Frame:GetChildren()) do
if v:IsA('ImageButton') then
if v.Name == PlayersHouse then
v.Bottom.Price.Text = 'SELECTED'
v.Bottom.Price.TextColor3 = Color3.fromRGB(255, 255, 255)
else
v.Bottom.Price.Text = 'SELECT'
v.Bottom.Price.TextColor3 = Color3.fromRGB(255, 255, 255)
end
end
end
You donât need to check âif Price.Text == âSELECTâ thenâ.