Hey i was just wondering if you know why this script doesn’t work
Its supposed to teleport the player to different obbies when clicking any image buttons inside of the table but only the buttontable[1] works at teleporting the player.:
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]