Okay so for the past few days I'm been modifying a script for a game I'm making. I have run into another problem though. My script is supposed to display a TextLabel when there are not enough players in the lobby to start the game. Since I was sure I had completely fixed the script I had expected to see one when I tested my game alone but nothing appeared. This worries me because if the first label didn't work I'm sure the rest will have problems too. Can anyone help me find the problem in the script?
--Main variables
local Maps = game.ReplicatedStorage.Maps:GetChildren()
local Players = game.Players
local Murderer = nil
local sherrif = nil
local Dead ={}
local Spawn = "Workspace.Center" -- input the path to your main spawn point where players enter the game
local MaxGameTime = 120 -- how long you want your game to run.(In seconds)
local ToggleGame = 1
local Knife = game.ReplicatedStorage.Knife
local Revolver = game.ReplicatedStorage.Revolver
local NotFinished = true
-- Main loop
m = Instance.new("TextLabel", game.StarterGui.ScreenGui.TextLabel)
m.Size = UDim2.new(0, 500, 0, 50) --Make sure to use UDim2, NOT Vector3
m.Position = UDim2.new(.5, -500, .5, -340)
m.TextColor = Color3.new(1, 1, 1)
m.Text = "Stuff" --Make sure this is a string
m.BorderSizePixel = (1.5)
m.BackgroundColor3 = Color3.new(1, 1, 1) --GUIs only accept Color3 values, which range from 0 to 1. To convert other colors to Color3, divide each number by 255. In this case, white is (255, 255, 255) and 255/255 = 1.
m.BackgroundTransparency = (1)
function GameHandle()
local Winner = ""
if #Players:GetChildren() <2 then return "Must be at least two players"
end
Murderer = Players:GetChildren()[math.random(1,#Players:GetChildren())]
Sherrif = Players:GetChildren()[math.random(1,#Players:GetChildren())]
while Sherrif == Murderer do
Sherrif = Players:GetChildren()[math.random(1,#Players:GetChildren())]
wait()
end
local Map = Maps[math.random(1,#Maps)]:Clone()
Map.Parent = workspace
for _, P in ipairs(Players:GetChildren()) do P.Character:MoveTo(Map.PrimaryPart.Position) end
local m
for i = 5,0 do
m.Text = i
wait(1)
end
m:Destroy()
Sherrif.Character.Humanoid:EquipTool(Revolver:Clone())
Murderer.Character.Humanoid:EquipTool(Knife:Clone())
Murderer.Character.Humanoid.Died:connect(function() end)
local function CheckPlayers() while true do if #Dead == (#Players:GetChildren() - 1) then return true end end end
for _,z in ipairs(Players:GetChildren()) do
z.Died:connect(function()
Died = Died + 1
if Died == #Players:getChildren() then
Winner = "Murderer"
end
end)
end
Murderer.Character.Died:connect(function() Winner = "Innocents" end)
local Index = 0
while wait(1) do
Index = Index + 1
if Index == MaxGameTime then
return "Innocents"
end
end
return Winner
end
while true do
for _, P in ipairs(Players:GetChildren()) do P.Character:MoveTo(workspace.Center.Position) end
local m = Instance.new("TextLabel", game.StarterGui.ScreenGui.TextLabel)
m.Text = GameHandle().." Wins!"
wait(2)
m:Destroy()
wait(10)
end
Thank to anyone who can help me!!
