When a player kills all the players, it shows a GUI that they won
Does any one know how to do that?
When a player kills all the players, it shows a GUI that they won
Does any one know how to do that?
I’m guessing that the game would have 3 teams; Spectators, Killer, Survivors.
When a survivor dies, they switch to the spectator team. The game checks if there are no more survivors left, and if so then show the GUI to the players that the killer has won.
But the surviours will be kicked from the game, so the GUI would only be shown to the killer
Here is the script Idk if you could identify the problem
local players = game:GetService("Players")
local player = game.Players.LocalPlayer
local PlayerWon = game.StarterGui.PlayerWon.TextLabel --show the killer the GUI when all the survivours are kicked/dead!
players.Died:Connect(function()
PlayerWon.Visible = true
end)
I am not sure what you mean by this line:
players.Died:Connect(function()
its an FFA Game. When all the player are dead/kicked the Killer will be shown a GUI that they won!!
--Server
local players = game.Players:GetPlayers
if #players == 1 then --#players is the anmount of players that are in the server.
RemoteEvent:FireAllClients() --There's only one client so we don't have to get the player.
end
--Client
RemoteEvent.OnClientEvent:Connect(function()
Text.Text = "You win"
end
Where will i place the Server and the Client Script
You can put the serverScript in serverScriptService
and the local script in every player
The client goes anywhere where it works, i’d recommend to put it in a screengui with a textlabel, and the Serverscript in serverscriptservice. Make sure you declare the Text and RemoteEvent variable!!
Also the script has to check it regularly. Only checking it once isn’t enough. (serverscript)
What about the Remote Event. where should i place the Remote Event?
Replicated Storage. That’s a service both client and server can access.
its not working!
let me rephrase my statement! There is only one player remaining, a Text Gui will pop up!!
Can u help me?
Serverscript:
local players = game.Players:GetPlayers()
repeat wait() until #players == 1 or #players == 0
local Message = Instance.new("Hint")
Message.Parent = workspace
Message.Text = "You won"
wait(5)
Message:Destroy()
This should work.
local players = game:GetService("Players")
local playerList = players:GetChildren()
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
for i, v in pairs(playerList) do
if v.Name == player.Name then
table.remove(playerList, i)
end
end
end)
end)
end)
while task.wait() do
if #playerList == 1 then
print(playerList[1], "has won the game!")
elseif #playerList == 0 then
print("Everyone has died!")
end
end
This won’t reset the player list if you plan on having a rounds based system but you can add that.
It worked! Thank you very much!