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)
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.