Hey Developers!
I am just making a wins adder for my story game.
I am teleporting players from the main game into the lobby once the game has finished.
It is supposed to give them a win.
Here is my script in the main game:
for _, Player in pairs(game.Players:GetChildren()) do
spawn(function()
local NewGui = game.ServerStorage.Assets.GoodEnding:Clone()
NewGui.Parent = Player.PlayerGui
wait(5)
local TeleportData = {
AddWins = true,
PlayerName = Player.UserId
}
TeleportService:Teleport(4832886851, Player, TeleportData)
end)
end
Here is my wins adder script(In the lobby)
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
I am getting no errors but nothing is happening!
Help is appreciated.
Seems to suggest it needs to be done within a local script, given you are using ServerStorage and then trying to set what I assume would be a value needed by the server, I assume you’re using a normal script?
Yes, you do put it in there. Like the thread I’ve sent you, you should make your script look similar to this:
local TeleportService = game:GetService("TeleportService")
local RunService = game:GetService("RunService")
local Data = TeleportService:GetLocalPlayerTeleportData()
if not RunService:IsStudio() then
if TeleportData ~= nil then
print("Data")
else
print("No Data") -- Prints "No Data"
end
end