my script teleports a player to a different game when the players lives reaches 0 but it doesnt work and i get this error
“Argument 2 missing or nil”
heres my script
local LivesFld = game.ReplicatedStorage.LiveEvents
local ts = game:GetService("TeleportService")
local placeid = "10197848753"
--put your place's id there ^
local Debounce = {}
LivesFld.DiedFired.OnServerEvent:Connect(function(Player)
if Debounce[Player] then return end
Debounce[Player] = true
local Lives = Player:WaitForChild("SystemFolder"):WaitForChild("Lives")
Lives.Value -= 1
Player.CharacterAdded:Connect(function()
if Lives.Value <= 1 then
Lives.Value = 1
spawn(function()
ts:TeleportAsync(placeid, Debounce[Player])
end)
end
end)
wait(.25)
Debounce[Player] = nil
end)
Ok, this is because TeleportAsync() has the second argument as objects meaning an array, if you would like to do it that way then you would have to TeleportService:TeleportAsync(YOUR_PLACE_ID_HERE, {Player}) -- where player is the parameter from the RemoteEvent.
It’s really simple just put brackets and put the player in it, like so:
local LivesFld = game.ReplicatedStorage.LiveEvents
local ts = game:GetService("TeleportService")
local placeid = "10197848753"
--put your place's id there ^
local Debounce = {}
LivesFld.DiedFired.OnServerEvent:Connect(function(Player)
if Debounce[Player] then return end
Debounce[Player] = true
local Lives = Player:WaitForChild("SystemFolder"):WaitForChild("Lives")
Lives.Value -= 1
Player.CharacterAdded:Connect(function()
if Lives.Value <= 1 then
Lives.Value = 1
spawn(function()
ts:TeleportAsync(placeid, {Player})
end)
end
end)
wait(.25)
Debounce[Player] = nil
end)
Can you post me the client script of where it fires the remote?. If you want to test it outside the game, you’ll have to make it public or at least only developers can teleport to it.