Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game.Players
- local RS = game:GetService("ReplicatedStorage")
- local Events = RS.RemoteEvents
- local ProfileStore = require(game.ReplicatedStorage.ProfileStore)
- local function RestartChar(Char, Plr: Player)
- print("YES")
- Plr:SetAttribute("Spectating", false)
- local Hum: Humanoid = Char:FindFirstChildOfClass("Humanoid") or Char:WaitForChild("Humanoid")
- Hum.Died:Once(function()
- if workspace.Values.GameActive.Value == false then
- task.wait(2)
- Plr:LoadCharacter()
- return
- end
- Plr:SetAttribute("Spectating", true)
- local AllPlayersDead = true
- for _, plr in Players:GetPlayers() do
- if not plr.Character then continue end
- local Hum: Humanoid = Char:FindFirstChildOfClass("Humanoid") or Char:WaitForChild("Humanoid")
- if Hum.Health > 0 then
- AllPlayersDead = false
- end
- end
- if AllPlayersDead and workspace.Values.GameActive.Value == true then
- workspace.Values.GameActive.Value = false
- workspace.Enemies:ClearAllChildren()
- Events.SendMessage:FireAllClients("[System]: All players have died. Restarting...")
- task.wait(5)
- for _, plr in Players:GetPlayers() do
- plr:LoadCharacter()
- end
- end
- task.wait(26)
- if Plr and Plr.Parent and Plr:GetAttribute("Spectating") == true then
- Plr:LoadCharacter()
- end
- end)
- end
- game.Players.PlayerAdded:Connect(function(plr)
- plr:LoadCharacter()
- RestartChar(plr.Character, plr)
- plr.CharacterAdded:Connect(function(char)
- RestartChar(char, plr)
- local ff = Instance.new("ForceField", char)
- game.Debris:AddItem(ff, 3)
- end)
- plr.Chatted:Connect(function(msg)
- if string.lower(msg) == ";ff" then
- Instance.new("ForceField", plr.Character)
- end
- end)
- end)
- local Values = {
- Wins = {
- RagmasterWins = 5
- }
- }
- local PlayerData = ProfileStore.New("PlayerData", Values)
- local Profiles: {[player]: typeof(PlayerData:StartSessionAsync())} = {}
- local function PlayerAdded(player: Player)
- local Id = tostring(player.UserId)
- local Profile = PlayerData:StartSessionAsync(Id, {
- Cancel = function()
- return player.Parent ~= Players
- end,
- })
- if Profile ~= nil then
- Profile:AddUserId(player.UserId)
- Profile:Reconcile()
- Profile.OnSessionEnd:Connect(function()
- Profile[player] = nil
- player:Kick("Profile session end - please rejoin")
- end)
- if player.Parent == Players then
- Profiles[player] = Profile
- print("Profile loaded for " .. player.Name)
- print(Profile.Data)
- local fold = Instance.new("Folder", player)
- fold.Name = "leaderstats"
- local wins = Instance.new("IntValue", fold)
- wins.Name = "Wins"
- for _, bosswins in Profile.Data.Wins do
- wins.Value += bosswins
- end
- else
- Profile:EndSession()
- end
- else
- player:Kick("Data load failed, please rejoin.")
- end
- end
- Players.PlayerAdded:Connect(PlayerAdded)
- Players.PlayerRemoving:Connect(function(player)
- local profile = Profiles[player]
- if profile ~= nil then
- profile:EndSession()
- end
- end)
- Events.BossBar.Event:Connect(function(gradient: UIGradient, char: Model)
- if not char then return end
- local bar = RS.BossBars.BossBar:Clone()
- gradient:Clone().Parent = bar.BossBar
- for _, plr: Player in Players:GetPlayers() do
- local plrgui = plr:WaitForChild("PlayerGui")
- local BossBars = plrgui:WaitForChild("BossBars")
- if BossBars then
- print("WOOOOWOOWOWH FOUND")
- local barclone = bar:Clone()
- barclone.Character.Value = char
- barclone.LocalScript.Enabled = true
- barclone.Parent = plr.PlayerGui.BossBars.BossBar
- end
- end
- local joinconnect = Players.PlayerAdded:Connect(function(plr: Player)
- local plrgui = plr:WaitForChild("PlayerGui")
- local BossBars = plrgui:WaitForChild("BossBars", 5)
- if BossBars then
- local barclone = bar:Clone()
- barclone.Character.Value = char
- barclone.LocalScript.Enabled = true
- barclone.Parent = plr.PlayerGui.BossBars.BossBar
- end
- end)
- char:FindFirstChildOfClass("Humanoid").Died:Once(function()
- joinconnect:Disconnect()
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement