** NOTICE**: Why doesn't the Gui show up at all? Its normally supposed to tell each person teleported what there Class is (Bloxxer, Bystander, or Sheriff), and tell everyone who won as a result, I don't know why?!
This is the Main-script in ServerScriptService!
local roundtime = 60 * 5
local intermissiontime = 20
local serverstorage = game:GetService("ServerStorage")
local replicatedstorage = game:GetService("ReplicatedStorage")
local debris = game:GetService("Debris")
local event = replicatedstorage:WaitForChild("RemoteEvent")
local maps = serverstorage:WaitForChild("maps")
local mapholder = game.Workspace:WaitForChild("MapHolder")
local statustag = replicatedstorage:WaitForChild("StatusTag")
local timertag = replicatedstorage:WaitForChild("TimerTag")
-- (I script some code to get to the main part)
while true do
--Load random map
statustag.Value = "Loading Map"
timertag.Value = -1
mapholder:ClearAllChildren()
wait(2)
local allmaps = maps:GetChildren()
local newmap = allmaps[math.random(1,#allmaps)]:clone()
newmap.Parent = game.Workspace.MapHolder
wait(2)
-- Wait for Contestants
while true do
wait(5)
contestants = {}
for _,player in pairs(game.Players:GetPlayers())do
if player and player.Character then
local humanoid = player.Character:WaitForChild("Humanoid")
if humanoid and humanoid.Health > 0 then
table.insert(contestants, player)
end
end
end
if #contestants >= 3 then
break
else
statustag.Value = "Waiting for Players"
timertag.Value = -1
end
end
statustag.Value = "Match"
timertag.Value = roundtime
-- Choose a Bloxxer
bloxxer = contestants[math.random(1, #contestants)]
-- Choose Sheriff
while true do
randomplayer = contestants [math.random(1, #contestants)]
if randomplayer ~= bloxxer then
sheriff = randomplayer
break
end
end
-- teleport contestants
local spawnsmodel = newmap:WaitForChild("Spawns")
local spawns = spawnsmodel:GetChildren()
for _,player in pairs(contestants) do
if player and player.Character and #spawns > 0 then
local torso = player.Character:WaitForChild("Torso")
local humanoid = player.Character:WaitForChild("Humanoid")
local spawnindex = math.random(1, #spawns)
local spawn = spawns[spawnindex]
if spawn and torso and humanoid then
humanoid.Health = 100
humanoid.WalkSpeed = 16
table.remove(spawns, spawnindex)
torso.CFrame = CFrame.new(spawn.Position + Vector3.new(0, 3, 0))
local matchtag = Instance.new("StringValue")
matchtag.Name = "MatchTag"
matchtag.Parent = player.Character
local backpack = player:FindFirstChild("Backpack")
if backpack then
if player == bloxxer then
local knife = serverstorage:WaitForChild("Knife"):clone()
knife.Parent = backpack
event:FireClient(player, "Class", "Bloxxer")
elseif player == sheriff then
local gun = serverstorage:WaitForChild("Gun"):clone()
gun.Parent = backpack
event:FireClient(player, "Class", "Sheriff")
else
event:FireClient(player, "Class", "Bystander")
end
end
end
end
end
spawnsmodel:remove()
print(game.Players.NumPlayers)
wait(0.001)
print()
-- timer
local localtimer = roundtime
while localtimer > 0 do
wait(1)
localtimer = localtimer - 1
timertag.Value = localtimer
activecontestants = {}
bloxxeractive = false
for _,player in pairs(contestants) do
if player then
local character = player.Character
if character then
local matchtag = character:FindFirstChild("MatchTag")
local humanoid = character:FindFirstChild("Humanoid")
if matchtag and humanoid and humanoid.Health > 0 then
if player == bloxxer then
bloxxeractive = true
end
table.insert(activecontestants, player)
end
end
end
end
if #activecontestants <=1 or not bloxxeractive then
break
end
end
print("TEst11")
local gameresults = "PlayersWin"
if bloxxeractive then
if #activecontestants > 2 then
--bloxxer failed
event:FireAllClients("Result","PlayersWin")
else
--Bloxxer wins!
gameresult = "BloxxerWin"
event:FireAllClients("Result","BloxxerWin")
end
else
--bloxxer captured
event:FireAllClients("Result","PlayersWin")
end
print("TEst12")
for _,v in pairs(game.Workspace:GetChildren()) do
if v and v.Name == "pickup" or v.Name == "Hat" then
v:remove()
end
end
print("TEst13")
for _, player in pairs(contestants)do
if player then
if gameresult == "BloxxerWin" and player == bloxxer then
awardpoints(player, 9)
elseif gameresult ~= "BloxxerWin" and player ~= bloxxer then
if player == sheriff then
awardpoints(player, 4)
else
awardpoints(player,2)
end
end
end
end
Now the GUI based part, This is the LocalScript inside of the GUI.
local gui = script.Parent
local replicatedstorage = game:GetService("ReplicatedStorage")
local statustag = replicatedstorage:WaitForChild("StatusTag")
local timertag = replicatedstorage:WaitForChild("TimerTag")
local statustitle = gui:WaitForChild("StatusTitle")
local event = replicatedstorage:WaitForChild("RemoteEvent")
local resultprompt = gui:WaitForChild("ResultPrompt")
local resultname = resultprompt:WaitForChild("ResultName")
local resultdesc = resultprompt:WaitForChild("ResultDescription")
local classprompt = gui:WaitForChild("ClassPrompt")
local classname = classprompt:WaitForChild("ClassName")
local classdesc = classprompt:WaitForChild("ClassDescription")
--(Skipped to the [Might be] broken part)
statustitle.TextColor3 = Color3.new (0, 255, 0)
elseif statustag.Value == "Match" then
statustitle.TextColor3 = Color3.new(255, 85, 0)
elseif statustag.Value == "Loading Map" or statustag.Value == "Waiting for players" then
statustitle.TextColor3 = Color3.new(255, 0, 255)
end
end
timertag.Changed:connect(updatestatus)
statustag.Changed:connect(updatestatus)
updatestatus()
event.OnClientEvent:connect(function(...)
local tuple = (...)
if tuple[1]== "Result" then
if tuple[2] == "BloxxerWin" then
resultname.Text = "Mad Bloxxer Wins!"
resultname.TextColor3 = Color3.new(255, 0, 0)
resultdesc.Text = "All Players Were Bloxxed."
else
resultname.Text = "Players Win!"
resultname.TextColor3 = Color3.new(170, 255, 255)
resultdesc.Text = "Players have won!"
end
local player = game.Players:GetPlayerFromCharacter()
local GetResultPrompt = player:FindFirstChild("PlayerGui")
player.GetResultPrompt.ResultPrompt.Visible = true
wait(7)
elseif tuple [1] == "Class" then
if tuple[2] == "Bloxxer" then
classname.Text = "You are the mad bloxxer"
classname.TextColor3 = Color3.new(255, 0, 0)
classdesc.Text = "Your goal is to blox everyone"
elseif tuple[2] == "Sheriff" then
classname.Text = "You are th sheriff"
classname.TextColor3 = Color3.new(255, 255, 127)
classdesc.Text = "kill the bloxxer!!!"
else
classname.Text = "You are a bystander"
classname.TextColor3 = Color3.new(170, 170, 255)
classdesc.Text = "Help the sheriff find the mad bloxxer!"
end
local player = game.Players:GetPlayerFromCharacter()
local GetClassPrompt = player:FindFirstChild("PlayerGui")
player.GetClassPrompt.ClassPrompt.Visible = true
wait(7)
end
end)
THIS IS THE GUI BASED PART!
- ScreenGUI
LocalGuiScript
StatusTitle
ClassPrompt
- ClassDescription
- ClassName
ResultPrompt
- ResultDescription
- ResultName
THIS IS WHATS IN THE REPLICATEDSTORAGE!
- StatusTag (String Value)
- TimerTag (Int Value)
- RemoteEvent

1 comment
thanks