#im pretty confused at this bug.
1 messages · Page 1 of 1 (latest)
local function startRound()
local activePlayersList = {}
local activePlayersData = {}
local deathConnections = {}
local touchConnections = {}
local chosenMap
while #Players:GetPlayers() < playerLimit do
statusUpdate:FireAllClients("Minimum two players required to play!")
task.wait(1)
end
for i = intermissionTime, 0, -1 do
statusUpdate:FireAllClients("Intermission: " .. i .. " seconds left!")
task.wait(1)
end
statusUpdate:FireAllClients("Game Starting!")
task.wait(2)
statusUpdate:FireAllClients("")
if #mapQueue == 0 then
shuffle()
end
chosenMap = mapQueue[1]:Clone()
chosenMap.Parent = workspace
table.remove(mapQueue, 1)
local spawnPart = chosenMap:WaitForChild("SpawnLocation")
repeat task.wait() until chosenMap:IsDescendantOf(workspace)
roundInProgress = true
if chosenMap then
local spawnPosition = spawnPart.Position
for _, player in Players:GetPlayers() do
table.insert(activePlayersList, player)
print("Inserted into the table: " .. player.Name)
task.spawn(function()
local character = player.Character or player.CharacterAdded:Wait()
character:WaitForChild("HumanoidRootPart")
local randomOffset = Vector3.new(math.random(-5, 5), 3, math.random(-5, 5))
character:PivotTo(CFrame.new(spawnPosition + randomOffset))
print("Successfully teleported " .. player.Name)
end)
end
end
Another issue is sometimes the players might fall down the map because of slower connection since the map hasnt loaded on their client. How can I make sure a player only teleports when the map loads on their client?
@vocal phoenix do u mind helping ?
while #Players:GetPlayers() < playerLimit do
statusUpdate:FireAllClients("Minimum two players required to play!")
task.wait(1)
end
rather then just looping through the player instances also try checking if the player has a corresponding character object, this pretty much confirms all players have loaded.
you can do this by looping through all players and confirming atleast the minimum amount of players have a loaded character
by "loaded character" i mean an occupied
.Character```
attribute on the player object.
Something like if player.character then..?
yes.
local playersWithCharacters = 0
while playersWithChararcters < playerLimit do
playersWithCharacters = 0
for i,v in pairs(game.Players:GetChildren()) do
if v:IsA("Player") then
if player.Character then
playersWithCharacters +=1
end
do
end
statusUpdate:FireAllClients("Minimum two players required to play!")
task.wait(1)
end
something like this should work. @misty vine
lemme try
if an error does occur please be sure to send over output.
alr
u have inserted an invalid player instance btw, it should be v.Character since u gave the items in the list the name 'v'
oh, my bad! i wasnt doing this within the roblox script editor, just writing on discord chat 😓
please be sure to correct my mistake in your script.
no worries!
I will also print the value of playersWithCharacters, just incase it was another bug
** You are now Level 5! **
Hold isnt ur script kinda placed in the wrong place. This means the loop will stop working along with all if conditions inside it if player count hits 2
its doing the same thing as before but with the player character this time? yes itll end the while loop once character count hits 2
I mean if player count exceeds one, I don't think it would be ideal to use this script in a while loop-
? i dont think im getting you, either way it should work the same way as before just with an extra check, im not seeing the problem here. if you have output errors please send them over.
Not sure if that should be ideal. I mean yeah, sure we are making sure the minimum amount of players has a loaded character. But I do not understand how would that be ideal in helping with the teleportation issue. Shouldn't we make sure the player characters have loaded first right in the teleportation loop if player character not loaded is the issue?
the teleportation issue occurs due to the players character // game not being fully loaded, you can either create remote event listener that confirms if the clients game loaded property is true or you can simply confirm if the physical character is loaded.
if the teleportation errors persist then perhaps add a 3 second teleport delay after the clone becomes a descendant of workspace?
The intermission is 10 seconds though, so shouldnt that be more than enough for the character to load. Also I have added a few seconds delay but for some reason my character spawns right under the map
i meant a delay for the map to fully load
oh
if you teleport right when a map spawns it MAY not load fully on all clients.
Some player have network issues which means the map may have not loaded fully on their client so they teleport right under the map. How can I make sure the map loads for the player first and then they should teleport?
you'd need clientside confirmation; perhaps fire a teleport event to the client to confirm if the map exists, then teleport them clientside
(clientside teleports are still visible on the server)
(just like editing the walkspeed clientside)
oh
local spawnPart = chosenMap:WaitForChild("SpawnLocation")
repeat task.wait() until chosenMap:IsDescendantOf(workspace)
task.wait(3)
roundInProgress = true
if chosenMap then
local spawnPosition = spawnPart.Position
for _, player in Players:GetPlayers() do
table.insert(activePlayersList, player)
print("Inserted into the table: " .. player.Name)
task.spawn(function()
local character = player.Character or player.CharacterAdded:Wait()
if character then
repeat task.wait() until character:FindFirstChild("HumanoidRootPart")
local randomOffset = Vector3.new(math.random(-5, 5), 3, math.random(-5, 5))
character:PivotTo(CFrame.new(spawnPosition + randomOffset))
print("Successfully teleported " .. player.Name)
end
end)
end
end
@nova pier do u think this would work?
added several checks
repeat task.wait().... is just incase if anything fails since player tp'd from hrp
it should!
the task.wait(3) makes player spawn below the map-