Random Teleport trough a Fired Remote Event

Hello,
so to start quickly I want the player/players to be teleported to a random part trough a Fired Remote Event

8866eedbbc45eddd434fde6e705b93f4
I have these parts in workspace and now I want the player to be teleported to a random 1 of them trough a fired remote event if this is possible pls tell me
anyways have a good day

Why do you need to teleport them through a RemoteEvent? Can’t this just be done on the server?

If you want a server-sided implementation or just general code for an implementation:

local RNG = Random.new()

local spawns = workspace:WaitForChild("Spawns"):GetChildren() -- assuming all spawns are within a model / parent folder

local function teleportManyPlayers(players) -- players is an array of players to teleport.
	for _, player in next, players do
		if not player.Character or not player.Character.PrimaryPart then
			continue
		end
		local ranSpawn = spawns[RNG:NextInteger(1, #spawns)]
		player.Character:SetPrimaryPartCFrame(ranSpawn.CFrame + Vector3.new(0, 6, 0))
	end
end


--some implementation of the function
1 Like