Trying to send info from a server to another when player leaves/gets teleported

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    When the player gets teleported to send a value from a place to another

  2. What is the issue? Include screenshots / videos if possible!
    I already have it implemented and it can send through but the issue is that it seems that when the player leaves and Roblox shuts down the server that the message doesn’t get sent through or when the player leaves it completely stops sending

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I haven’t tried much so far and have looked for solutions and couldn’t find much to help.

I had both places running and when I left the first place it sent over to the other place and loaded my character in, without both servers being active the data doesn’t get sent

-- Main place sending the info (does send when player leaves)
local function OnPlayerRemoving(player:Player)
	local PlayerData = DataStoreModule.find("PlayerData", "player-"..player.UserId)
	
	if ChosenSlot ~= nil then
		MessagingService:PublishAsync(tostring(player.UserId .. "_data"), ChosenSlot)
		print("Sent data")
	end
	
	if PlayerData ~= nil then
		PlayerData:Destroy()
	end
end

-- Other place receiving the info
MessagingService:SubscribeAsync(tostring(player.UserId .. "_data"), function(message)
		print(message["Data"]) -- prints nothing nor receives anything
	end)

A couple of things:

  1. Messaging Service is Not designed for this. Messaging Service can and will fail. Simply put, Messaging Service is a Best effort and not guaranteed. Which in this case is and can be a big deal.

→ From the roblox docs on MessagingService:

“Delivery is best effort and not guaranteed. Make sure to architect your game so delivery failures are not critical.”

  1. You keep talking about teleporting. Is there a reason why SetTeleportData and Player:GetJoinData() is not an option? I highly recommending use this if possible. Unless I’m not understanding the topic, this lookjs like the best solution.

  2. If the Above is not an option. How about Datastores or MemoryStores (I would recommend Memory stores then datastores as datastores can yield for Getting and Reading data)? Would you be able to use these Services over Messaging Service. IF none of these options are suitable, please explain in your reply why these wouldn’t work vs. what you have with MessagingService.

1 Like

I was reading about teleportation data and I read that it was unsecure so I was unsure if I should use it.

Yes technically it is unsecure, which is why Datastores / Memory stores were my next option. Teleport data could be important for values you may not care about, like for example I had a party system which teleports you to a horror type game. People could change the settings for the party to allow certain things in the horror. It would be pointless to protect this because it was a literal setting on a Gui before they joined. If your passing along currency or other data that might be important, Data or Memory stores can be used to help you. You can use them independently or You could also do a mix of both. Like when the player Joins you get the join data and believe them, but you run on a check on the server that the value you saved in the datastore is the same value as the one in :GetJoinData() (The reason why you may do this is you still have a value if datastores fail which may be nice). This is just an example on what you could do it make it more secure

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.