Hello, im a new developer and im working on my game.
I have this script which teleports players to GameBricks when the game starts. but, I have a huge problem! When the game starts the script teleports players to a different gamebrick each. I want them to all teleport to the same one. How can I do this?
heres the round start part of the script. the part that teleports the players.
function m_fnHandleActiveGame() if (ActiveRound.Value == true and RoundTime.Value == m_iTimerLength) then for i, player in ipairs(game.Players:GetChildren()) do max = Model.GameBricks:GetChildren() randomlocation = math.random(1,#max) m_fnTeleportTo(max[randomlocation], player, i)
All help is appreciated.
This is because the spawn randomization is specified within the pairs
loop, therefore for each Player
iterated, the spawn will change.
It's a quick and simple fix, simply allocate the chosen spawn within a variable, and define it outside of the pairs
scope.
function m_fnHandleActiveGame() if (ActiveRound.Value and RoundTime.Value == m_iTimerLength) then -- local randomlocation = math.random(1,#max) for i, player in ipairs(game.Players:GetChildren()) do max = Model.GameBricks:GetChildren() m_fnTeleportTo(max[randomlocation], player, i) end end end