Teleporting a player doesn't work correctly

image
I am building lobby teleports that get you to the game, everything works fine but when the player wants to leave the teleport it sometimes moves them back to the wrong teleporter (sometimes both of them leave you in front of ‘1 Player’ and sometimes the opposite, I think it depends on the order of ‘leavePart’ in the explorer)
It was grouped in Models and tried Folders but no luck, also tried naming the leavePart and models different names and also didn’t work.
all the parts in the teleports are named the same by the way.
image

leaveGuiEvent.OnServerEvent:Connect(function(player)
	if player.Character then
		player.Character:MoveTo(script.Parent.leavePart.Position)
		removeFromList(player.Character)
	end
end)

I also use the same parts for the player camera and they work fine, they display the correct teleporter…

I think the issue is that you have not really correctly defined which part to move to. You get the part from the script parent however how .OnServerEvent works is that it will send to all scripts causing me to assume the issue is due to you having the event inside of two scripts so the one which sends last will teleport you to that or something in regards to that.

This could be fixed easily by passing in through the remote event (or on the server side it self already) have which folder it is and do it that way.

I kind of understood the problem, but I still didn’t understand how to solve it. How do I detect the player is in which teleporter?

As you said, all the scripts were receiving the remote event and I solved it by checking whether the player was on the list. Thanks for your quick reply.

here how the script turned out:

leaveGuiEvent.OnServerEvent:Connect(function(player)
	for i=1, #list do
		if list[i] == player.Character.Name then
			if player.Character then
				player.Character:MoveTo(script.Parent.leavePart.Position)
				removeFromList(player.Character)
			end
		end
	end
end)

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