Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Player = game.Players.LocalPlayer
- local RunService = game:GetService("RunService")
- local CoreGui = game:GetService("StarterGui")
- local Character = Player.Character or Player.CharacterAdded:wait()
- local Humanoid = Character:WaitForChild("Humanoid")
- local UI = script.Parent--Player.PlayerGui:WaitForChild("SpectateUI")
- local SpectateButton = UI.SpectateButton
- local SpectateFrame = UI.SpectateFrame
- local PreviousButton = SpectateFrame.BackRoundImage.PreviousButton
- local ClickSound = Player.PlayerGui:WaitForChild("LocalSounds")["Clicked Sound"]
- local ShopButton = Player.PlayerGui:WaitForChild("ShopUI").OpenShopButton
- local CodesButton = Player.PlayerGui:WaitForChild("CodesUI").OpenShopButton
- local StatsButton = Player.PlayerGui:WaitForChild("StatsGui").StatsButton
- local CoinsShopButton = Player.PlayerGui:WaitForChild("Coins&GemsShop").CoinsShopButton
- local GemsShopButton = Player.PlayerGui:WaitForChild("Coins&GemsShop").GemsShopButton
- local DieButton = Player.PlayerGui:WaitForChild("ButtonGui").Die
- local LobbyButton = Player.PlayerGui:WaitForChild("ButtonGui").Lobby
- local ExtraLifeUI = Player.PlayerGui:WaitForChild("ExtraLifesFrame")
- local LevelsUI = Player.PlayerGui:WaitForChild("LevelsGui")
- local NextButton = SpectateFrame.BackRoundImage.NextButton
- local PlayerNameLabel = SpectateFrame.PlayerNameLabel
- local Camera = workspace.CurrentCamera
- local Reconnect
- local num --= 0
- UI.Enabled = true
- SpectateButton.MouseButton1Click:Connect(function()
- ClickSound:Play()
- if SpectateFrame.Visible then
- SpectateButton.Position = UDim2.new(0.137, 0,0.43, 0)
- DieButton.Position = UDim2.new(0.68,0,0.875,0)
- ExtraLifeUI.Frame.Position = UDim2.new(0.53, 0,0.865, 0)
- ShopButton.Visible = true
- CodesButton.Visible = true
- StatsButton.Visible = true
- CoinsShopButton. Visible = true
- GemsShopButton.Visible = true
- --DieButton.Visible = true
- if Player.PlayerGui:WaitForChild("SpeedTimer") then
- Player.PlayerGui:WaitForChild("SpeedTimer").Enabled = true
- end
- SpectateButton.BackgroundColor3 = Color3.new(0.333333, 1, 0)
- SpectateFrame.Visible = false
- PlayerNameLabel.Text = Player.Name
- Camera.CameraSubject = Player.Character.Humanoid
- CoreGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
- num = 1
- LevelsUI.Stage.Position = UDim2.new(0.155, 0,0.925, 0)
- LevelsUI.StageDescription.Position = UDim2.new(0.04, 0,0.925, 0)
- LobbyButton.Position = UDim2.new(0.325,0,0.875,0)
- else
- SpectateButton.Position = UDim2.new(0.008, 0,0.43, 0)
- ShopButton.Visible = false
- CodesButton.Visible = false
- StatsButton.Visible = false
- CoinsShopButton. Visible = false
- GemsShopButton.Visible = false
- --DieButton.Visible = false
- SpectateButton.BackgroundColor3 = Color3.new(1, 0, 0)
- SpectateFrame.Visible = true
- LevelsUI.Stage.Position = UDim2.new(0.155, 0,1.2, 0)
- LevelsUI.StageDescription.Position = UDim2.new(0.04, 0,1.2, 0)
- DieButton.Position = UDim2.new(0.68,0,1.275,0)
- LobbyButton.Position = UDim2.new(0.325,0,1.275,0)
- ExtraLifeUI.Frame.Position = UDim2.new(0.53, 0,1.2, 0)
- -- PlayerNameLabel.Text = Player.Name
- -- Camera.CameraSubject = Player.Character.Humanoid
- num = 2
- local Players = game.Players:GetPlayers()
- local all = #Players
- if not Players[num] then
- PlayerNameLabel.Text = Player.Name
- Camera.CameraSubject = Player.Character.Humanoid
- CoreGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
- else
- num = 2
- Camera.CameraSubject = Players[num].Character.Humanoid
- PlayerNameLabel.Text = Players[num].Name
- CoreGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
- end
- if Player.PlayerGui:WaitForChild("SpeedTimer") then
- Player.PlayerGui:WaitForChild("SpeedTimer").Enabled = false
- end
- end
- end)
- PreviousButton.MouseButton1Click:Connect(function()
- ClickSound:Play()
- local Players = game.Players:GetPlayers()
- local all = #Players
- num = num - 1
- if num < 1 then
- num = all
- end
- Camera.CameraSubject = Players[num].Character.Humanoid
- PlayerNameLabel.Text = Players[num].Name
- end)
- NextButton.MouseButton1Click:Connect(function()
- ClickSound:Play()
- local Players = game.Players:GetPlayers()
- local all = #Players
- num = num + 1
- if num > all then
- num = 1
- end
- Camera.CameraSubject = Players[num].Character.Humanoid
- PlayerNameLabel.Text = Players[num].Name
- end)
- Player.CharacterAdded:Connect(function(Char)
- if SpectateFrame.Visible then
- local Players = game.Players:GetPlayers()
- if Char then
- if Players[num] then
- if Players[num].Name == Char.Name then
- Camera.CameraSubject = Char:WaitForChild("Humanoid")
- PlayerNameLabel.Text = Char.Name
- elseif Players[num].Name ~= Char.Name then
- local OtherPlayerName = Players[num].Name
- if game.Workspace:FindFirstChild(OtherPlayerName) then
- task.wait(.1)
- local OtherCharacter = game.Workspace:FindFirstChild(OtherPlayerName)
- Camera.CameraSubject = OtherCharacter:WaitForChild("Humanoid")
- PlayerNameLabel.Text = OtherCharacter.Name
- end
- end
- end
- end
- end
- end)
- game.Players.ChildRemoved:Connect(function(LeftPlayer)
- -- warn(LeftPlayer.Name)
- if SpectateFrame.Visible then
- if PlayerNameLabel.Text == LeftPlayer.Name then
- local Players = game.Players:GetPlayers()
- if Players[num] then
- local OtherPlayerName = Players[num].Name
- if game.Workspace:FindFirstChild(OtherPlayerName) then
- task.wait(.1)
- local OtherCharacter = game.Workspace:FindFirstChild(OtherPlayerName)
- Camera.CameraSubject = OtherCharacter:WaitForChild("Humanoid")
- PlayerNameLabel.Text = OtherCharacter.Name
- end
- else
- num = 2
- PlayerNameLabel.Text = Player.Name
- Camera.CameraSubject = Player.Character.Humanoid
- end
- end
- end
- end)
- task.wait(10)
- RunService.RenderStepped:Connect(function()
- local Players = game.Players:GetPlayers()
- if num ~= 0 then
- if Players[num] then
- if Players[num].Name ~= Player.Name then
- local OtherPlayerName = Players[num].Name
- if game.Workspace:FindFirstChild(OtherPlayerName) then
- local OtherCharacter = game.Workspace:FindFirstChild(OtherPlayerName)
- Camera.CameraSubject = OtherCharacter:WaitForChild("Humanoid")
- PlayerNameLabel.Text = OtherCharacter.Name
- end
- end
- end
- end
- task.wait(.1)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement