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
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?
start elseing your prints with return (print 'no map', map)
return print('no spawns', map:FindFirstChild("Spawn"))
could help you/us
Not having spawns isnt the issue.
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.
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)
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!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.