So basically I was trying to make a voting system compatible with the round script, but now it broke th round script, and I added print statements, it doesn’t print “Hi2”, “C”, or “T”
-- Local script in voting frame
local Classic = game.ReplicatedStorage.Classic
local Teams = game.ReplicatedStorage.Teams
local VotingOn = game.ReplicatedStorage.VotingOn
local status = game.ReplicatedStorage.VotingStatus
local Vote = game.ReplicatedStorage.Vote
local chosen
script.Parent.Classic.MouseButton1Click:Connect(function()
if chosen ~= "Classic" then
game.ReplicatedStorage.Vote:FireServer(chosen, "Classic")
chosen = "Classic"
script.Parent.Visible = false
end
end)
script.Parent.Teams.MouseButton1Click:Connect(function()
if chosen ~= "Teams" then
game.ReplicatedStorage.Vote:FireServer(chosen, "Teams")
chosen = "Teams"
script.Parent.Visible = false
end
end)
while wait() do
script.Parent.Classic.TextLabel.Text = Classic.Value .." Votes"
script.Parent.Teams.TextLabel.Text = Teams.Value .." Votes"
end
-- script in serverscriptservice, used also for the voting system
game.ReplicatedStorage.Vote.OnServerEvent:Connect(function(player, previous, chosen)
local votes = game.ReplicatedStorage[chosen]
votes.Value = votes.Value + 1
if previous ~= nil then
local prev = game.ReplicatedStorage[previous]
prev.Value = prev.Value - 1
end
end)
for i = 10,1,-1 do
game.ReplicatedStorage.VotingStatus.Value = i .." seconds to vote"
wait(1)
end
local votes = {game.ReplicatedStorage.Classic, game.ReplicatedStorage.Teams}
table.sort(votes, function(a,b)
return a.Value > b.Value
end)
local chosen = votes[1].Name
if chosen == "Classic" then
print("Classic")
game.ReplicatedStorage.WhichGamemode:Invoke(chosen)
print("C")
else
print("Teams")
game.ReplicatedStorage.WhichGamemode:Invoke(chosen)
print("T")
end
-- Another script in serversciptservice for rounds
repeat wait()until #game.Players:GetPlayers() >= 1
local text = game.ReplicatedStorage.Value
local Maps = game.ServerStorage:GetChildren()
function Intermission()
game.ReplicatedStorage.ShowVotes:FireAllClients()
workspace.Sound1:Play()
for i = 10,1,-1 do
text.Value = "Intermission "..i
wait(1)
end
print("Yay")
game.ReplicatedStorage.Function:Fire()
print("yay2")
end
Intermission()
game.ReplicatedStorage.Function2.Event:Connect(function()
print("Hi")
local function Gamemode()
wait()
game.ReplicatedStorage.WhichGamemode.OnInvoke = function(chosen)
print("Hi2")
print(chosen)
if chosen == "Teams" then
print("Teams")
else
print("Classicaa")
end
wait(5)
local function Gamemode()
wait()
game.ReplicatedStorage.WhichGamemode.OnInvoke = function(chosen)
print("Hi2")
game.Workspace.Sound1:Stop()
local ChosenMap = Maps[math.random(1,#Maps)]:Clone()
print(ChosenMap)
ChosenMap.Parent = workspace
ChosenMap.Name = "LoadedMap"
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = game.Workspace:WaitForChild("LoadedMap").SpawnPlayersToMap.CFrame
end
wait()
game.Workspace:WaitForChild("LoadedMap").Sound:Play()
for _, player in pairs(game.Players:GetPlayers()) do
end
for i = 5,1,-1 do
text.Value = ("Round Starting in ".. i)
wait(1)
end
for _, player in pairs(game.Players:GetChildren()) do
local sword = game.ReplicatedStorage.ClassicSword:Clone()
sword.Parent = player.Backpack
sword = game.ReplicatedStorage.ClassicSword:Clone()
sword.Parent = player.StarterGear
end
for i = 6,1,-1 do
text.Value = (i)
wait(1)
if i == 1 then
for _, player in pairs(game.Players:GetChildren()) do
local sword = player.Backpack:FindFirstChild("ClassicSword")
local sword2 = player.StarterGear:FindFirstChild("ClassicSword")
local char = player.Character
if sword then sword:Destroy() end
if sword2 then sword2:Destroy() end
if char then
local sword = char:FindFirstChild("ClassicSword")
if sword then sword:Destroy() end
end
end
for _, player in pairs(game.Players:GetChildren()) do
if player.Backpack:FindFirstChild("AzureSword") == true or player.StarterGear:FindFirstChild("AzureSword") then
player.Character:FindFirstChild("AzureSword"):Destroy()
player.Backpack:FindFirstChild("AzureSword"):Destroy()
player.StarterGear:FindFirstChild("AzureSword"):Destroy()
end
end
local function GetPlayerWithMostKills()
local Current, Plr = -1, nil;
for _, Player in ipairs(game:GetService("Players"):GetPlayers()) do --// ipairs is good for arrays; i++ order
if (Player.leaderstats.Kills.Value > Current) then
Plr = Player;
Current = Player.leaderstats.Kills.Value; --// Assign it to the highest found
end
end
return Plr, Current;
end
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local PlayerWithMostKills, Kills = GetPlayerWithMostKills();
print(PlayerWithMostKills)
-- Fetch the thumbnail
local userId = PlayerWithMostKills.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Dictionary = {
Player = PlayerWithMostKills;
Kills = Kills;
Content = content;
}
ReplicatedStorage.ShowNameAndKills:FireAllClients(Dictionary);
ReplicatedStorage.ShowImage:FireAllClients()
-- Set the ImageLabel's content to the user thumbnail
for _,player in ipairs(game.Players:GetChildren()) do
local imageLabel = player.PlayerGui.MostKills.Frame.PlrImage
imageLabel.Image = content
imageLabel.Size = UDim2.new(0, 166,0, 154)
end
wait(5)
game.ReplicatedStorage.CloseImage:FireAllClients()
game.Workspace:WaitForChild("LoadedMap").Sound:Stop()
for _, player in pairs(game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = game.Workspace:WaitForChild("LobbySpawnPart").CFrame
end
game.Workspace:WaitForChild("LoadedMap"):Destroy()
for _, player in pairs(game.Players:GetChildren()) do
if player.leaderstats.Kills.Value > 0 then
player.leaderstats.Kills.Value = 0
end
end
Gamemode()
end
end
end
end
end
end
end)
Thanks, and feel free to ask questions