local teleportService = game:GetService("TeleportService")
local teleportData = teleportService:GetLocalPlayerTeleportData()
if teleportData then
local Player = game.Players:GetPlayerByUserId(teleportData.PlayerName)
Player:WaitForChild('leaderstats'):WaitForChild('Wins').Value = Player.leaderstats.Wins.Value + 1
end
Script = ServerScriptService
local teleportService = game:GetService("TeleportService")
local TeleportData = {
AddWins = true,
PlayerName = Player.UserId
}
teleportService:Teleport(9368394776, Player, TeleportData)
This is on a LocalScript, when it needs to be on a ServerScript.
Assuming the ServerScript you provided teleports instantly after the win, and detecs when the win happens, here’s an edited version of the ServerScript.
Hey, im just here to point you a issue with the current script your trying to make. The teleport data is not sent on the server side but on the client side. This means that the client has direct access to the information in question. Exploiters can therefore modify this data during their teleportation or even initiate a teleportation with this data and exploit this to retrieve points in an unplanned way. The easiest way to prevent this is to use DataStoreService on the game server before you teleport the player to the lobby.
When the data concerns important game stats, you should never trust the client, and always be careful to check on the server side that all the client information you recive from remote event or functions has not been modified to exploit a “vulnerability” in your code