Hello! So Im trying to make a Elimination game, but you litterly cant come back because if you die or fall of the Baseplate, you get kicked lol. Im trying to make a script that will look for how many players their are in a game, if after the game startup figures out that their is 1 player then, it will say the players name and say “Looks Like “…playername…” Has Won The Game!”
Here’s my current script:
-- Defining Variables
local TutorialText = game.StarterGui.ScreenGui.TutorialText
local BaseplateStrinkScript = game.Workspace.Baseplate.Script
local PlayerGui = game:GetService("PlayerGui")
-- First Line Of Code
BaseplateStrinkScript.Disabled = true
-- Game Startup
wait(5)
PlayerGui.TutorialText.Visible = true
wait(4)
PlayerGui.TutorialText.Text = "In this game, Players must use the cars and Knock eachother off the Baseplate!"
wait(7)
PlayerGui.TutorialText.Text = "The Baseplate Will Strink Slowly so make sure you dont fall!"
wait(7)
PlayerGui.TutorialText.Text = "The Last player Standing Wins!"
wait(5)
PlayerGui.TutorialText.Text = "Goodluck, Players!"
wait(5)
BaseplateStrinkScript.Disabled = false
-- Looking For The Winner
Also, can I make it so if their is 1 player their is a localfunction that makes it so the baseplate script gets disabled BasePlateScriptStrink.Disabled = true?
local function TestFunction()
BasePlateScriptStrink.Disabled = true
end
game.Players.PlayerAdded:Connect(function()
if #game.Players:GetPlayers() == 1 then
TestFunction()
end
end)
game.Players.PlayerRemoving:Connect(function()
if #game.Players:GetPlayers() == 1 then
TestFunction()
end
end)
if you want to figure out how many players there are left, I would use the PlayerRemoving function along with #game.Players:GetPlayers()
local players = game.Players
players.PlayerRemoving:Connect(function()
if #players:GetPlayers() == 1 then
local winner = #players:GetPlayers()[1]
winner.PlayerGui.TutorialText.Text = "Looks like "..winner.Name.." has won the game!"
end
end)
local function checkPlayers(players)
if #players == 1 then
workspace.Baseplate["WhereverTheScriptIs"].Disabled = true
else
return nil
end
end
checkPlayers(#game.Players:GetPlayers());
local function checkPlayers(players)
if players == 1 then
workspace.Baseplate["WhereverTheScriptIs"].Disabled = true
else
return nil
end
end
checkPlayers(#game.Players:GetPlayers());