i want to make it so that when you touch a brick you get teleported into another game wich i dont know how to do, thanks!
local TeleportService = game:GetService("TeleportService") local PLACE = 13377628 -- put another game id in here function onTouched(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then TeleportService:Teleport(PLACE, player) end end script.Parent.Touched:connect(onTouched) --fires the function called onTouched --this script should be a server normal script with a part as parent
This script should teleport a player to the desired game id on the variable called PLACE
with use of the TeleportService API
To do this, you must use the TeleportService
provided by Roblox.
--First, you must "require" or "include" the service (name it whatever you want). You can do this simply by typing: local TeleportService = game:GetService("TeleportService") local PlaceID = 914206360 --Just an example Place ID --First, you need to create a function that is triggered when a player touches the brick, which you can do as follows: script.Parent.Touched:Connect(function (hit) --Now you have to get the player from the part that touched the brick local Player = game.Players:GetPlayerFromCharacter(hit.Parent) --Now I would recommend to test if the player was found. You can do that like this: if Player then --Now we can finally teleport the player like this: TeleportService:Teleport(PlaceID, Player) end end)