Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Teleporting into a different area instead of at spawn point when entering the game doesn't work?

Asked by 4 years ago

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?

0
Updated my answer Shawnyg 4330 — 4y

2 answers

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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")
0
It works but it says "Torso isn't a valid member of players" what do I do there?? panichub 29 — 4y
0
I'm not using r15, I'm using r6, it somewhat works but it doesn't teleport you in the designated location I put?? It just spawns you in a corner where you fall and die now. panichub 29 — 4y
Ad
Log in to vote
0
Answered by
haba_nero 386 Moderation Voter
4 years ago

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.

0
Well it is one place, but it has a lot of ways of getting to the same location just different areas panichub 29 — 4y
0
I don't want a simple teleport touch script, I want this one cause it is complicated panichub 29 — 4y
0
So you want more complicated script? haba_nero 386 — 4y
0
It's not that complicated as you think it is lol panichub 29 — 4y

Answer this question