Function code happens multiple times

That’s because :Once will disconnect after that Connection gets fired once, so in your case :Connect has more use to you since you’re teleporting them to random spawns every time they respawn

3 Likes

Yes, I would’ve used SpawnLocations, but there could be some problems such as players not getting weapons the second they spawn in, and overall, spawnlocations would cause some issues.

I see, is there a way to re-connect them? or will it never work until the function is ran again?

2 Likes
start elseing your prints with return (print 'no map', map)
return print('no spawns', map:FindFirstChild("Spawn"))

could help you/us

2 Likes

Not having spawns isnt the issue.

2 Likes

Ideally you want to set up the CharacterAdded connection to all players at the start of the round and call Disconnect() when the round ends (or whenever you don’t care about character spawns any more).

Alternatively (which is what I would most likely do) is set up the CharacterAdded connection up once when a player joins, and whenever it fires only teleport them if a round is ongoing.

4 Likes

setup a boolean named roundOnGoing and set it true/false yk when

local roundOnGoing = false

game.Players.PlayerAdded:Connect(function(player)
   player.CharacterAdded:Connect(function(character)
      if roundOnGoing and map then
         local spawns = map:FindFirstChild("Spawns", true)
         game.ReplicatedStorage.Teleport:FireClient(player, spawns)
      end
   end)
end)
4 Likes

Thank you so much! I made so it disconnects the function once the round value is set to false. Thank you all so much for your help!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.