So, like in RPG games, if you were to enter a house from it would put you at the beginning of the door. But, if you came in the back way, it would lead you in at the back door not the front door.
I would like this function, but with teleporting to another place, and grabbing the data of the teleport service, and you teleported from one part of the map, it would teleport you to the second place, but in a different location instead of the original spawn point. Like lets say there is a cave that leads to a town (The town is the different place), and a road that also leads to it, players heading through the road would be spawned at the road way they came from in the town. While players that went through the cave would be spawned by the cave entrance where they came from and into the town.
This is the first script to the first game. Basically if you click the part it teleports you to the game. script in click detector on a part
local TeleportService = game:GetService("TeleportService") local placeID_1 = 4505065903 local placeID_2 = 4483453486 script.Parent.MouseClick:Connect(function(player) TeleportService:Teleport(placeID_1, player,"Why") end) script.Parent.MouseClick:Connect()
local script in Startergui
local Data = game:GetService("TeleportService"):GetLocalPlayerTeleportData() print (Data) if Data == true then wait(.1) game.Players.Parent:FindFirstChild("Humanoid") game.Players.Torso.CFrame = game.Workspace.Finish.CFrame + Vector3.new(-103.2, 108.7, -129.7) end
This is the script to the second game. It is successful with printing "Why" in the output, but it doesn't move the player to the designated area...I really don't know how to go about this script, is there a better way to do this??? Or what I'm doing wrong at least?
The code works as you wrote it, but clearly not how you wan t it. I assume the Data == true
is to see if Data exists. Rather, do if Data then
or if Data ~= nil then
. Comparing it to the boolean true
would always return false if the Data variable isn't explicitly defined as true.
Edit:
-- Instead of game.Players.Torso.CFrame -- Put game.Players.LocalPlayer.Character.Torso.CFrame -- I advise you to use HumanoidRootPart since R15 doesn't have Torso -- Instead of game.Players.Parent:FindFirstChild("Humanoid") -- Put game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
Try this: Put this in the part:
local Teleport = game.Workspace:FindFirstChild("Door")--Name of another part. Put this part in front of the front door script.Parent.Touched:Connect(function(touched) local Human = touched.Parent:FindFirstChild("HumanoidRootPart") if Human then Human.CFrame = Teleport.CFrame + Vector3.new(0,5,0) end end
I suggest you use teleporters for this. Putting multiple places inside one game just gets too complicated. Plus, It's actually easier to make one giant map rather than multiple places.