LocalPlayerArrivedFromTeleport isn't firing RemoteEvent

Hello, I’m trying to get a badge awarded if a player is teleported from a different game. I’m using LocalPlayerArrivedFromTeleport. Here’s the local script in ReplicatedFirst that sends fires the event:

local TeleportService = game:GetService("TeleportService")
local Remote = game.ReplicatedStorage.Hidden.RemoteEvent

TeleportService.LocalPlayerArrivedFromTeleport:Connect(function()
	
	Remote:FireServer()
	
	
end)

Here is the script that finds if the remoteevent is fired, it’s in ServerScriptService:

game.ReplicatedStorage.Hidden:WaitForChild("RemoteEvent").OnClientEvent:Connect(function(Player)
	
	game:GetService("BadgeService"):AwardBadge(Player.UserId, 2124636304)
	
	
end)

Any help is appreciated, thanks.

i prefer use TP:LocalPlayerTeleportData() and fire remote if its not nil

1 Like

You’re using the wrong event, on the server you’ll want to use OnServerEvent.

1 Like

How would I check if it’s nil?

make something like that in localscript

    local data = game.TeleportService:GetLocalTeleportData()
    local remote = -- your remote
    if data then
        remote:FireServer(data)
    end

but you can use LocalPlayerArrivedFromTeleport() to check if player arrived from teleport.
retournevrai has right, you used OnClientEvent

How would the script know which player to get the teleport data from?

its a localscript lol

In the output it says, “GetLocalTeleportData() isn’t a member of teleport service”.

Thanks, but I tried using OnServerEvent, but it was the same result, it didn’t award the badge.

Odd, it may be worth using @Lap_124’s answer but try putting the LocalScript inside StarterPlayerScripts and use the GetLocalPlayerTeleportData.

This may be farfetched however I believe a race condition is happening here, the remote is being fired before it’s connected to.

2 Likes

So something like this?

local TeleportService = game:GetService("TeleportService")

local teleportData = TeleportService:GetLocalPlayerTeleportData()

local remote = game.ServerStorage:WaitForChild("RemoteEvent")
if teleportData then
remote:FireServer()

end)

Almost, just remove the parenthesis on this end:

And wasn’t the remote in ReplicatedStorage? LocalScripts can’t reach ServerStorage.

Yes, the remote event is in ReplicatedStorage, just had to think of an example at the top of my head.

1 Like