Script sometimes doesn't teleport players to a certain location

So I have a script that works perfectly fine with any other player on both sides, except me on the right. What should happen is that the localscript gets the localplayer teleport data and checks to see if the players name is in the first or second slot of the table. If it finds the player in the left slot, it fires the server with a string with the side name and then teleports the player.

What I don’t understand is that the script doesn’t work with my player for some reason. It will only work on the right side and not the left. It is really strange.

local:

local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer

local playersInGame = TeleportService:GetLocalPlayerTeleportData()

if playersInGame then
	if playersInGame[1] == player.Name then
		game.ReplicatedStorage.PlayerPlacement:FireServer("Left")
	elseif playersInGame[2] == player.Name then
		game.ReplicatedStorage.PlayerPlacement:FireServer("Right")	
	end
end

server:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")


ReplicatedStorage.PlayerPlacement.OnServerEvent:Connect(function(plr, side)
	local char = plr.Character or plr.CharacterAdded:Wait()
	if side == "Left" then
		local HRP = char:WaitForChild("HumanoidRootPart")
		
		HRP.CFrame = CFrame.new(31.65, 10, 358.571)
	elseif side == "Right" then
		local HRP = char:WaitForChild("HumanoidRootPart")
		
		HRP.CFrame = CFrame.new(2.493, 10, 358.571)		
	end
end)

do not trust the Client for this kind of system, the exploiters could use it

2 Likes

all it really does is place a player on the left or right, I’m sure exploiters would really only use exploits for crazy times, credit gain, car hacking, and rank changing. though i will consider this, this isn’t really that helpful in my case.

you know, you’d be amazed at what an exploit could do with just that,underestimating them is a mistake, they can ruin the game experience For the problem of hacking cars of rank or credits, these are rare errors in the code of the game because they are very easy to avoid, however some people forget it or are not aware of it, there are also backdoor but these other things