What I mean by this is how could I create a script that uses strings to identify certain players/usernames and teleport them to a game ID of my choice, kind of like the banland script BIG studios put into their "BIG Paintball" Game.
This is quite simple.
All you need to do is create a server script
in ServerScriptService
then input this code:
Player's Username Script
01 | local placeid = 00000000000 -- The Banland Place ID |
02 |
03 | local tps = game:GetService( "TeleportService" ) -- Gets TP Service |
04 |
05 | local banned = { -- Banned Users |
06 | "User1" , |
07 | "User2" , |
08 | "User3" , |
09 | "User4" |
10 | } |
11 |
12 | game.Players.PlayerAdded:Connect( function (player) -- If A Player Joins Runs The Code |
13 | if table.find(banned,player.Name) then -- Checks if Player On List Is Equal To The Player's Username |
14 | tps:Teleport(placeid,player) -- Teleports The User To Banland |
15 | end |
16 | end ) |
Note: THE ABOVE IS USING PLAYER'S USERNAMES. USE THE SCRIPT BELOW FOR PLAYER IDs!
Player's User ID
01 | local placeid = 00000000000 -- The Banland Place ID |
02 |
03 | local tps = game:GetService( "TeleportService" ) -- Gets TP Service |
04 |
05 | local banned = { -- Banned User's ID |
06 | 00000000000 , |
07 | 00000000000 , |
08 | 00000000000 , |
09 | 00000000000 |
10 | } |
11 |
12 | game.Players.PlayerAdded:Connect( function (player) -- If A Player Joins Runs The Code |
13 | if table.find(banned,player.UserId) then -- Checks if Player On List Is Equal To The Player's ID |
14 | tps:Teleport(placeid,player) -- Teleports The User To Banland |
15 | end |
16 | end ) |
If you have any questions. just contact me!
I'd like to see your attempt next time.
01 | local TeleportService = game:GetService( "TeleportService" ) |
02 | local Players = game:GetService( "Players" ) |
03 |
04 | local UserIdList = { |
05 | 905646521 , --[[ Your Id ]] |
06 | 74087102 --// Mine |
07 | } |
08 |
09 | local TeleportPlaceId = --// Place Id |
10 |
11 | Players.PlayerAdded:Connect( function (Player) |
12 | if (UserIdList [ Player.UserId ] ) then |
13 | TeleportService:Teleport(TeleportPlaceId, Player) |
14 | end |
15 | end ) |
Closed as Not Constructive by Ziffixture
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?