Created
July 30, 2021 16:57
-
-
Save RobertCodez/e59cb9974fc2231112cbcd5763f59fb2 to your computer and use it in GitHub Desktop.
Arena Invitations | Shows the use of remote events to provoke all the clients
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
game.ReplicatedStorage.JoinArena.OnServerInvoke = function(plr) | |
if plr:FindFirstChild("Arena") == nil then | |
Instance.new("BoolValue",plr).Name = "Arena" | |
plr.ChildRemoved:Connect(function(child) | |
if child.Name == "Arena" then | |
local amount = 0 | |
local theWinner | |
for _,player in pairs(game.Players:GetPlayers()) do | |
if player:FindFirstChild("Arena") then | |
amount = amount + 1 | |
theWinner = player | |
end | |
end | |
if amount <= 0 then | |
game.ReplicatedStorage.GuiReplicator:FireAllClients("WinnerAnnounce", "Nobody") | |
wait(10) | |
game.ServerStorage.ArenaBeingUsed.Value = false | |
elseif amount == 1 then | |
game.ReplicatedStorage.GuiReplicator:FireAllClients("WinnerAnnounce", theWinner.Name) | |
wait(50) | |
game.ServerStorage.ArenaBeingUsed.Value = false | |
end | |
end | |
end) | |
end | |
end | |
repeat | |
wait(20) | |
if not game.ServerStorage.ArenaBeingUsed.Value then | |
game.ReplicatedStorage.GuiReplicator:FireAllClients("ArenaInvitation") | |
wait(10) | |
for _,player in pairs(game.Players:GetChildren()) do | |
if player:FindFirstChild("Arena") then | |
for _,cock in pairs(workspace.Chickens:GetChildren()) do | |
if cock.Owner.Value == player.Name and not cock:FindFirstChild("Chicken") then | |
Instance.new("BoolValue", cock).Name = "Chicken" | |
end | |
end | |
game.ServerStorage.ArenaBeingUsed.Value = true | |
game.ReplicatedStorage.GuiReplicator:FireClient(player, "ArenaInstructions") | |
end | |
end | |
end | |
until game == nil | |
local part = Instance.new("Part",workspace) | |
part.Position = workspace.WideArena.Cam1.CFrame.LookVector * 10 | |
game.Players.PlayerAdded:Connect(function(plr) | |
local char = plr.Character or plr.CharacterAdded:Wait() | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment