Link Locking
Hey there! Looking to QA test your game, or have your friends try a game before it releases? How is it possible to restrict access to users who you don’t have added, or aren’t in your group?
Recently, Roblox released developer deeplinking, which makes it possible to set launch data through a link.
Creating The Code
Your first step is to create a server script in ServerScriptService
!
Below is some well-commented code you can tinker with. Put this code in your new script!
local PlayersService = game:GetService("Players")
local KickMessage = "You do not have permissions to join this experience." -- The frontfacing kick message an invalid player sees
local JoinDataKey = "link-unlock" -- Matches the information after "&launchData="
PlayersService.PlayerAdded:Connect(function(Player)
local JoinData = Player:GetJoinData().LaunchData
-- LaunchData is a property of JoinData
if JoinData then -- Does the join data exist?
if JoinData == JoinDataKey then -- Is the join data equal to what we want?
-- The launch data matches JoinDataKey, output a message signifying a join!
warn(Player.Name .. " has joined the experience")
else
-- The launch data is incorrect, kick!
Player:Kick(KickMessage)
end
else
-- There is not any launch data, kick!
Player:Kick(KickMessage)
end
end)
Creating the Link
The link to safely join your game should look something like this:
https://www.roblox.com/games/start?placeId=(PLACEIDHERE)&launchData=link-unlock
Replace (PLACEIDHERE) with the place id of your game!
To break down the link,
-
https://www.roblox.com/games/start
signifies to roblox that the game is to be opened immediately, -
?placeId=(PLACEIDHERE)
signifies what game is to be played, - and
&launchData=link-unlock
sends a payload of data; in this case, “link-unlock”.
To Sum it Up
This is a super simple way to lock your game behind a link. As long as you’re not worried about the link being leaked, you can customize it how you want and share it with those you trust.
Thanks for the read!