How would I fix this GUI script?

Hello, Im currently trying to make a Weaponshop ui but I don’t know how to script it. I already tried something but that didn’t work.
That are the scripts I tried to use:
Here is what my ScreenGUI looks like:
Screenshot 2022-10-22 004222

Does someone know how I would fix it? I want to make it so, that if you click on the Unlselected Selected Image Button that the Selected Image Button will become visible and the other not visible. And for the other Weapon Frames that are not selected, it will show the Unselected Image. I don’t know if that’s understandable.

Script 1:

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.G36Selected.ImageTransparency = 0
	script.Parent.G36UnselectedImageButton.ImageTransparency = 1
	script.Parent.Parent.MP4Selected.ImageTransparency = 1
script.Parent.Parent.MP4Selected.MP4SelectedViewportFrame.ImageTransparency = 1
end)

Script 2:

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.MP4Selected.ImageTransparency = 0
	script.Parent.MP4Selected.MP4SelectedViewportFrame.ImageTransparency = 0
	script.Parent.MP4Selected.MP4UnselectedImageButton.ImageTransparency = 1
	script.Parent.MP4Selected.MP4UnselectedViewportFrame.ImageTransparency = 1
end)

You appeared to have cut off the script from above, can you fix that

And a Question,

What do you want to do with the UI?
Are you trying to open / close it?

I fixed the post. I have a Selected and Unselected Button (maybe It was stupid to make it as a Button). It looks like that if that’s better to understand. Purple is selected and grey is unselected. Basically there are 2 ImageButtons and 1 is visible and the other one invisible.

for i, v in pairs(parent_of_frames:GetChildren()) do
	v.MouseButton1Click:Connect(function()
		v.(property_of_border).Color = (color_you_want)
		for _, b in pairs(parent_of_frames:GetChildren()) do
			if b.Name ~= v.Name then
				v.(property_of_border).Color = (color_you_want)
			end
		end
	end)
end

just replace the stuff in brackets to properties or variables

watch out for that grammar error

if b.Name ~= v.Name then"

Edit: Fixed now

2 Likes