-- Services local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") -- Local Player and Character local LocalPlayer = Players.LocalPlayer local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait() local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart") -- Remotes and Game Objects local StageUpdateRemote = ReplicatedStorage:WaitForChild("StageUpdate") local StagesFolder = game.Workspace:WaitForChild("Stages") -- GUI Creation local ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = "SCAGENT_WinTeleport" ScreenGui.Parent = LocalPlayer.PlayerGui local MainFrame = Instance.new("Frame") MainFrame.Size = UDim2.new(0, 250, 0, 120) MainFrame.Position = UDim2.new(0.5, -125, 0.9, -60) MainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30) MainFrame.BorderSizePixel = 0 MainFrame.Draggable = true MainFrame.Parent = ScreenGui local TitleLabel = Instance.new("TextLabel") TitleLabel.Size = UDim2.new(1, 0, 0.25, 0) TitleLabel.Position = UDim2.new(0, 0, 0, 0) TitleLabel.BackgroundColor3 = Color3.fromRGB(50, 50, 50) TitleLabel.TextColor3 = Color3.fromRGB(255, 255, 255) TitleLabel.Font = Enum.Font.SourceSansBold TitleLabel.TextSize = 20 TitleLabel.Text = "SC-AGENT Win Teleport" TitleLabel.Parent = MainFrame local TeleportButton = Instance.new("TextButton") TeleportButton.Size = UDim2.new(0.9, 0, 0.6, 0) TeleportButton.Position = UDim2.new(0.05, 0, 0.32, 0) TeleportButton.BackgroundColor3 = Color3.fromRGB(0, 120, 180) TeleportButton.TextColor3 = Color3.fromRGB(255, 255, 255) TeleportButton.Font = Enum.Font.SourceSansBold TeleportButton.TextSize = 22 TeleportButton.Text = "Teleport to Win (Finding Stage...)" TeleportButton.Parent = MainFrame -- Teleport Logic TeleportButton.MouseButton1Click:Connect(function() Character = LocalPlayer.Character if not Character then return end HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart") if not HumanoidRootPart then return end local TargetStageNumber = 61 -- Default assumed final stage based on UIUpdate script local TargetPart = nil local HighestFoundStageNumber = 0 local HighestFoundStagePart = nil -- Iterate through children of the Stages folder to find the highest numbered stage for _, obj in ipairs(StagesFolder:GetChildren()) do local StageNum = tonumber(obj.Name:match("%d+$")) -- Extract number from end of string (e.g., "Stage61" -> 61) if StageNum and StageNum > HighestFoundStageNumber then HighestFoundStageNumber = StageNum HighestFoundStagePart = obj end end -- If a highest numbered stage was found, use that. if HighestFoundStagePart then TargetPart = HighestFoundStagePart TargetStageNumber = HighestFoundStageNumber TeleportButton.Text = "Teleport to Win (Stage " .. TargetStageNumber .. ")" else -- As a fallback, try to find "Stage61" or similar directly if no numbered stages were found TargetPart = StagesFolder:FindFirstChild("Stage" .. TargetStageNumber) or StagesFolder:FindFirstChild("Stage " .. TargetStageNumber) or StagesFolder:FindFirstChild(tostring(TargetStageNumber)) end if TargetPart then local TeleportCFrame = TargetPart.CFrame if TargetPart:IsA("Model") and TargetPart.PrimaryPart then TeleportCFrame = TargetPart.PrimaryPart.CFrame elseif TargetPart:IsA("BasePart") then TeleportCFrame = TargetPart.CFrame else -- If it's a model without PrimaryPart, try to find a suitable part inside local SpawnPart = TargetPart:FindFirstChild("SpawnLocation") or TargetPart:FindFirstChild("Spawn") or TargetPart:FindFirstChild("Part") if SpawnPart and SpawnPart:IsA("BasePart") then TeleportCFrame = SpawnPart.CFrame end end HumanoidRootPart.CFrame = TeleportCFrame + Vector3.new(0, 5, 0) -- Add height to prevent sticking -- Attempt to update the client's TeleportedStage value local TeleportedStageValue = LocalPlayer:FindFirstChild("TeleportedStage") if TeleportedStageValue and TeleportedStageValue:IsA("NumberValue") then TeleportedStageValue.Value = TargetStageNumber end -- Fire the remote to inform the server about the stage update StageUpdateRemote:FireServer(TargetStageNumber) print("SC-AGENT: Teleported to Stage " .. TargetStageNumber .. " and fired StageUpdate remote.") else warn("SC-AGENT: Could not find target stage part for Stage " .. TargetStageNumber .. " or highest stage.") end end) -- Initial update of button text local InitialHighestStageNumber = 0 for _, obj in ipairs(StagesFolder:GetChildren()) do local StageNum = tonumber(obj.Name:match("%d+$")) if StageNum and StageNum > InitialHighestStageNumber then InitialHighestStageNumber = StageNum end end if InitialHighestStageNumber > 0 then TeleportButton.Text = "Teleport to Win (Stage " .. InitialHighestStageNumber .. ")" else TeleportButton.Text = "Teleport to Win (Stage 61)" end