Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Holder = script.Parent:WaitForChild("Frame")
- local SpectatingText = Holder.Frame.PlayerName
- local RestartText = Holder.Restart
- local Next = Holder.Next
- local Previous = Holder.Previous
- local BossFrame = script.Parent.Parent:WaitForChild("BossBars")
- local Players = game:GetService("Players")
- local Player = Players.LocalPlayer
- local Camera = workspace.CurrentCamera
- local IsDead = false
- local PlayerList = {}
- Holder.Visible = false
- local function GetHumFromPlayer(plr: Player)
- local plrchar = plr.Character or plr.CharacterAdded:Wait()
- local h = plrchar:FindFirstChildOfClass('Humanoid') or plrchar:WaitForChild("Humanoid")
- return h
- end
- for _, plr in Players:GetPlayers() do
- if plr.Character then
- if plr.Character:FindFirstChildOfClass("Humanoid") then
- table.insert(PlayerList, plr)
- end
- end
- end
- Players.PlayerAdded:Connect(function(plr)
- GetHumFromPlayer(plr)
- table.insert(PlayerList, plr)
- end)
- Players.PlayerRemoving:Connect(function(plr)
- table.remove(PlayerList, table.find(PlayerList, plr))
- end)
- local function RestartChar(Char)
- print("YES")
- Holder.Visible = false
- BossFrame.Enabled = true
- Camera.CameraType = Enum.CameraType.Custom
- local Hum: Humanoid = Char:FindFirstChildOfClass("Humanoid") or Char:WaitForChild("Humanoid")
- Camera.CameraSubject = Hum
- IsDead = false
- Hum.Died:Once(function()
- if workspace.Values.GameActive.Value == false then return end
- Holder.Visible = true
- IsDead = true
- Camera.CameraType = Enum.CameraType.Watch
- SpectatingText.Text = Player.DisplayName
- BossFrame.Enabled = false
- for i = 25, 0, -1 do
- task.wait(1)
- RestartText.Text = "You respawn in: " .. i
- end
- end)
- end
- Player.CharacterAdded:Connect(function(Char)
- RestartChar(Char)
- end)
- Next.MouseButton1Click:Connect(function()
- if not IsDead then return end
- local Index = table.find(PlayerList, Player)
- Index += 1
- if Index > #PlayerList then
- Index = 1
- end
- local plr = PlayerList[Index]
- print(Index, PlayerList)
- SpectatingText.Text = plr.DisplayName
- Camera.CameraSubject = GetHumFromPlayer(plr)
- end)
- Previous.MouseButton1Click:Connect(function()
- if not IsDead then return end
- local Index = table.find(PlayerList, Player)
- Index -= 1
- if Index < 1 then
- Index = #PlayerList
- end
- local plr = PlayerList[Index]
- SpectatingText.Text = plr.DisplayName
- Camera.CameraSubject = GetHumFromPlayer(plr)
- end)
- if Player.Character then
- RestartChar(Player.Character)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement