- What do you want to achieve?
i want so if there are more than 2 player it should teleport the other players on the map and change their team
- What is the issue?
well as the title says it wont teleport the third player only the first two players
- What solutions have you tried so far?
nothing that i could think of.
local roundsystemmodule = require(game.ServerScriptService:WaitForChild("ModuleScripts"):WaitForChild("roundsystemodule"))
local votingmapmmodule = require(game.ServerScriptService:WaitForChild("ModuleScripts"):WaitForChild("votingmapmodule"))
local RunService = game:GetService("RunService")
local Waitingonplayers = game.ReplicatedStorage:WaitForChild("WaitingForplayersRemoteEvent")
local roundrunning = game.ReplicatedStorage:WaitForChild("roundrunning")
roundrunning.Value = true
local killerleft = game.ReplicatedStorage:WaitForChild("killerleft")
killerleft.Value = false
local survivorleft = game.ReplicatedStorage:WaitForChild("survivorleft")
survivorleft.Value = false
local currentkiller = game.ReplicatedStorage:WaitForChild("currentkiller")
local currentsurvivor = game.ReplicatedStorage:WaitForChild("currentsurvivor")
local function checkplayers()
local players = game.Players
local playertable = players:GetChildren()
for _, player in pairs(playertable) do
print(player.Name)
end
local enoughplayer = #playertable
if enoughplayer >= 2 then
Waitingonplayers:FireAllClients(roundrunning)
print("enough players")
return playertable , enoughplayer
else
Waitingonplayers:FireAllClients()
print("not enough players")
return playertable , enoughplayer
end
end
game.Players.PlayerAdded:Connect(function(player)
if roundrunning.Value == false then
checkplayers()
end
end)
game.Players.PlayerRemoving:Connect(function(player)
if currentkiller.Value == player then
killerleft.Value = true
print("killerleft")
checkplayers()
return
end
if currentsurvivor.Value == player then
survivorleft.Value = true
print("survivor left")
checkplayers()
return
end
checkplayers()
end)
while true do
task.wait(1)
local playertable, enoughplayers = checkplayers()
if enoughplayers >= 2 and roundrunning.Value == true then
roundrunning.Value = false
print("BEFORE VOTING:", #playertable)
local winningmap = votingmapmmodule.VotingSystem(playertable)
print("AFTER VOTING:", #playertable)
roundsystemmodule.Roundsystem(playertable, winningmap)
else
print("no round")
end
end
this is my server script i added prints, print(player.Name) it prints player1, player2 and player3 which should be three players in total right? but print(“AFTER VOTING:”, #playertable) it prints 2? and somehow print(“BEFORE VOTING:”, #playertable) doesn’t print at all, ive looked inside my module to see if i deleted or decreased the playertable or something
local module = {}
local maps = game:WaitForChild("ReplicatedStorage"):WaitForChild("Maps")
local tvmaps = game:WaitForChild("Workspace"):WaitForChild("ShowMapsTVS")
local killer = game:GetService("Teams").Killer
local survivor = game:GetService("Teams").Survivors
local votingsystemRemotevent = game:WaitForChild("ReplicatedStorage"):WaitForChild("votingsystemremotevent")
local votingmapandvotesRemotevent = game:WaitForChild("ReplicatedStorage"):WaitForChild("votingmapandvotesremotevent")
local tvguiremotevent = game:WaitForChild("ReplicatedStorage"):WaitForChild("TVGUI'sRemoteEvent")
local votingpad1 = game.Workspace:WaitForChild("VotingPad1")
local votingpad2 = game.Workspace:WaitForChild("VotingPad2")
local votingpad3 = game.Workspace:WaitForChild("VotingPad3")
local votingpadsdiscconect1 = nil
local votingpadsdiscconect2 = nil
local votingpadsdiscconect3 = nil
local roundrunning = game.ReplicatedStorage:WaitForChild("roundrunning")
function module.VotingSystem(playertable)
if roundrunning.Value == false then
local enoughplayers = #playertable
local highestnumber = 0
local winningmap = ""
local votes = {}
local mapvotes = {
Basement = 0,
Cellar = 0,
Caves = 0
}
local randommaps = {
"Basement",
"Cellar",
"Caves"
}
votingpadsdiscconect1 = votingpad1.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local playervote = votes[player]
playervote = "Basement"
tvguiremotevent:FireAllClients(mapvotes)
end
end)
votingpadsdiscconect2 = votingpad2.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local playervote = votes[player]
playervote[player] = "Cellar"
end
end)
votingpadsdiscconect3 = votingpad3.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local playervote = votes[player]
playervote[player] = "Caves"
end
end)
for i = 25, 0, -1 do
if enoughplayers <= 1 then
print("yoyoyoyoyoy")
break
else
print(i)
task.wait(1)
votingsystemRemotevent:FireAllClients(i)
if i <= 0 then
break
end
end
end
for _, vote in pairs(votes) do
if vote == "Basement" then
mapvotes.Basement += 1
elseif vote == "Cellar" then
mapvotes.Cellar += 1
elseif vote == "Caves" then
mapvotes.Caves += 1
end
end
for map, voteded in pairs(mapvotes) do
if voteded > highestnumber then
highestnumber = voteded
winningmap = map
votingmapandvotesRemotevent:FireAllClients(highestnumber, winningmap)
for _, sectionmap in pairs(maps:GetChildren()) do
if winningmap == "Basement" then
if sectionmap.Name == "Basement" then
print("it parent basement")
end
if winningmap == "Cellar" then
if sectionmap.Name == "Cellar" then
print("it parent cellar")
end
if winningmap == "Caves" then
if sectionmap.Name == "Caves" then
print("it parent caves")
end
end
end
end
end
end
end
if winningmap == "" then
local randommap = math.random(1, #randommaps)
winningmap = randommaps[randommap]
votingmapandvotesRemotevent:FireAllClients(highestnumber, winningmap)
end
return winningmap
else
return
end
end
return module
nothing, and inside the roundsystem module i have a print(#playertable) and it prints 2, i dont know what to do, im a beginner scripter, first time doing this kinds of systems so any help is greatly appreciated, if you want photos or something else, please reply and ill reply to you shortly.