Hi, im trying to make it so when there is no survivors left or the time runs out the killer gets 25 cash but i cant come up with how to do it, can someone help me understand a way to do it?
This is my main script
while true do
wait()
local numPlayers = #game.Players:GetChildren()
if numPlayers >= 2 then
break
end
end
--Killer/Survivor Picker
local killer = nil
local survivors = {}
local Picker = game.ReplicatedStorage.Picker
function PickPlayers()
survivors = {}
local plrs = game.Players:GetChildren()
local KillerID = math.random(1, #plrs)
for i, v in pairs(plrs) do
if i == KillerID then
killer = v.Name
break
end
end
for i, v in pairs(plrs) do
if i == KillerID then
else
table.insert(survivors, v.Name)
end
end
print("Killer: ".. killer)
for i, v in pairs(survivors) do
print("Survivor: ".. v)
end
end
while true do
PickPlayers()
print("Picked")
break
end
--Intermission, Roundtimer and Teleport
local roundLength = 100
local intermissionLength = 10
local InRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status
local LobbySpawn = game.Workspace.Lobby.Spawns.LobbySpawn
local GameAreaSpawn = game.Workspace.Maps.Hospital.Hallway.Spawns.MapSpawn
local KillerWaitingSpawn = game.Workspace.WaitingRoom.KillerWaitingSpawn
local KillerAreaSpawn = game.Workspace.Maps.Hospital.Hallway.Spawns.KillerMapSpawn
--Teleport
InRound.Changed:Connect(function()
if InRound.Value == true then
for i, v in pairs(survivors) do
game.Workspace[v].HumanoidRootPart.CFrame = GameAreaSpawn.CFrame
end
game.Workspace[killer].HumanoidRootPart.CFrame = KillerWaitingSpawn.CFrame
wait(10)
game.Workspace[killer].HumanoidRootPart.CFrame = KillerAreaSpawn.CFrame
end
end)
InRound.Changed:Connect(function()
if InRound.Value == false then
PickPlayers()
print("Picked")
for i, v in pairs(game.Players:GetChildren()) do
v.Character.HumanoidRootPart.CFrame = LobbySpawn.CFrame
end
end
end)
--Intermission and Roundtimer
local function roundTimer()
while wait() do
for i = intermissionLength, 0, -1 do
InRound.Value = false
wait(1)
Status.Value = "Intermission In ".. i .. ""
end
for i = roundLength, 0, -1 do
InRound.Value = true
wait(1)
Status.Value = "Game Ends In ".. i ..""
end
end
end
spawn(roundTimer)
This is the money script
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cash = Instance.new("IntValue")
cash.Name = "Cash"
cash.Value = 50
cash.Parent = leaderstats
end)
If you know a way to do it please leave a comment.
Thanks