The image label doesn't appear after clicking image button

  1. What do you want to achieve?
    When the image button is clicked on its supposed to open an image label.
    Here’s the script:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local textButton = script.Parent
local screengui = script.Parent.Parent.Parent
local ImageLabel = script.Parent.Parent
local obby1 = game.Workspace.obby1
local background = script.Parent.Parent.Parent.Background
local CamPart = game.Workspace.CamPart -- The part that camera changes its view to
local SettingsButton = screengui.Settings
local SettingsBackground = screengui.Settingsbackground
local ContinueButton = screengui.Settingsbackground.Continue1.Continue
local SettingsButton = screengui.Settingsbackground.Settings1.Settings
local LobbyButton = screengui.Settingsbackground.Lobby1.Lobby
local currentcamera = game.Workspace.CurrentCamera
local folder = screengui.Imagebuttons
--table with all of the imagebuttons
local buttontable = {folder.ImageButton, folder.ImageButton1, folder.ImageButton2, folder.ImageButton3, folder.ImageButton4, folder.ImageButton5, folder.ImageButton6, folder.ImageButton7, folder.ImageButton8, folder.ImageButton9, folder.ImageButton10, folder.ImageButton11, folder.ImageButton12, folder.ImageButton13, folder.ImageButton14, folder.ImageButton15, folder.ImageButton16, folder.ImageButton17, folder.ImageButton18, folder.ImageButton19, folder.ImageButton20}

wait(0.1)
ImageLabel.Visible = true
currentcamera.CameraType = Enum.CameraType.Scriptable
currentcamera.FieldOfView = 55
currentcamera.CFrame = CamPart.CFrame -- changes the cameras view to the view of the part

textButton.MouseButton1Click:Connect(function()
	textButton.Visible = false
	ImageLabel.Visible = false
	background.Visible = true
	for _, button in ipairs(buttontable) do
		button.Visible = true
	end
end)

buttontable[1].MouseButton1Click:Connect(function()
	for _, button in ipairs(buttontable) do
		button.Visible = false
	end
	background.Visible = false
	wait(0.5)
	humanoidRootPart.CFrame = obby1.CFrame
	currentcamera.CFrame = character.Head.CFrame
	currentcamera.FieldOfView = 70
	currentcamera.CameraType = Enum.CameraType.Custom
	SettingsButton.Visible = true -- this is supposed to make the settings button visible but its not working
end)

SettingsButton.MouseButton1Click:Connect(function()  -- when the settings button is clicked the settings background appears
	SettingsButton.Visible = false
	SettingsBackground.Visible = true
	SettingsBackground:TweenPosition(
		UDim2.new(0.364, 0,0.013, 0), 
		"Out", --easing direction
		"Quad", --easing style
		0.5, --time it takes to do action
		false --override other tweens
	)
end)

ContinueButton.MouseButton1Click:Connect(function() --makes the settings background invisible and makes the settings button visible
	SettingsButton.Visible = true
	SettingsBackground:TweenPosition(
		UDim2.new(0.382, 0,-0.859, 0),
		"Out", --easing direction
		"Quad", --easing style
		0.5, --time it takes to do action
		false --override other tweens
	)
	SettingsBackground.Visible = false
end)

It seems like you set the visibility to false, so maybe try setting it to true.

1 Like

Image Label is not what im trying to make visible but:

I should have specified that my mistake.

Does SettingsButton and buttontable[1] exist? If so, may you send a screen shot of the variables (and preferably more)?

1 Like

It’s in the code i sent:

and

the first imagebutton from the table is buttontable[1]

The whole script is what i already sent

Sorry, let me clarify: Can you send a picture of your hierarchy? Like not code, but the actual textlabels and stuff inside of explorer.

1 Like

My apologies, here it is:
-StarterGui


-Workspace
image

The script works until its time to make the settingsbutton appear.

Thank you for the picture! I have a question though; why is SettingsButton a variable twice? Which one doesn’t work?

1 Like

That was indeed the problem, thank you so much for the help, and sorry for the slow responses i was busy.

1 Like

That’s okay! Glad I could help, good luck on your project :wink: !

1 Like

Hey i was just wondering if you know why this script doesn’t work:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local textButton = script.Parent
local screengui = script.Parent.Parent.Parent
local ImageLabel = script.Parent.Parent
local obby1 = game.Workspace.obby1
local obby2 = game.Workspace.obby2
local obby3 = game.Workspace.obby3
local obby4 = game.Workspace.obby4
local obby5 = game.Workspace.obby5
local obby6 = game.Workspace.obby6
local obby7 = game.Workspace.obby7
local obby8 = game.Workspace.obby8
local obby9 = game.Workspace.obby9
local obby10 = game.Workspace.obby10
local obby11 = game.Workspace.obby11
local obby12 = game.Workspace.obby12
local obby13 = game.Workspace.obby13
local obby14 = game.Workspace.obby14
local obby15 = game.Workspace.obby15
local obby16 = game.Workspace.obby16
local obby17 = game.Workspace.obby17
local obby18 = game.Workspace.obby18
local obby19 = game.Workspace.obby19
local obby20 = game.Workspace.obby20
local obby21 = game.Workspace.obby21
local background = script.Parent.Parent.Parent.Background
local CamPart = game.Workspace.CamPart -- The part that camera changes its view to
local SettingsButton = screengui.SettingsButton
local SettingsBackground = screengui.Settingsbackground
local ContinueButton = screengui.Settingsbackground.Continue1.Continue
local SettingsButton1 = screengui.Settingsbackground.Settings1.Settings
local LobbyButton = screengui.Settingsbackground.Lobby1.Lobby
local spawnlocation = game.Workspace.SpawnLocation
local currentcamera = game.Workspace.CurrentCamera
local folder = screengui.Imagebuttons
--table with all of the imagebuttons
local buttontable = {folder.ImageButton, folder.ImageButton1, folder.ImageButton2, folder.ImageButton3, folder.ImageButton4, folder.ImageButton5, folder.ImageButton6, folder.ImageButton7, folder.ImageButton8, folder.ImageButton9, folder.ImageButton10, folder.ImageButton11, folder.ImageButton12, folder.ImageButton13, folder.ImageButton14, folder.ImageButton15, folder.ImageButton16, folder.ImageButton17, folder.ImageButton18, folder.ImageButton19, folder.ImageButton20}


buttontable[2].MouseButton1Click:Connect(function()
	for _, button in ipairs(buttontable) do
		button.Visible = false
	end
	background.Visible = false
	wait(0.5)
	humanoidRootPart.CFrame = obby2.CFrame + Vector3.new(0, 5, 0)
	currentcamera.CFrame = character.Head.CFrame
	currentcamera.FieldOfView = 70
	currentcamera.CameraType = Enum.CameraType.Custom
	SettingsButton.Visible = true
end)

buttontable[3].MouseButton1Click:Connect(function()
	for _, button in ipairs(buttontable) do
		button.Visible = false
	end
	background.Visible = false
	wait(0.5)
	humanoidRootPart.CFrame = obby3.CFrame + Vector3.new(0, 5, 0)
	currentcamera.CFrame = character.Head.CFrame
	currentcamera.FieldOfView = 70
	currentcamera.CameraType = Enum.CameraType.Custom
	SettingsButton.Visible = true
end) 
and so on until buttontable[21]

Its supposed to teleport the player to different obbies when clicking the image button but only the buttontable[1] works at teleporting the player.

For each obby variable, try using :WaitForChild() to get the object instead. The issue might be that obby2, obby3, and so on hasn’t loaded yet, meaning it is nil in this scenario.