I want to teleport players to another area in my game, but I don't know how. I need an example of Lua that will teleport people to the place I want. Thanks!
-Infina
I want to teleport players to another area in my game, but I don't know how. I need an example of Lua that will teleport people to the place I want. Thanks!
-Infina
Say for an example, you put a part into workspace, you'd put this script inside it:
local debounce = false
local coordinates = 0, 0, 0 --These are (in order) the XYZ coordinates to teleport to. Change it to what you like
script.Parent.Touched:connect(function(hit)
if not debounce then
if hit.Parent.Torso and hit.Parent.Humanoid then
hit.Parent.Torso.CFrame = CFrame.new(coordinates)
debounce = true
wait(4)
debounce = false
end
end
end)
This uses
CFrameandDebounceto help optimize this experience. I recommend looking at the ROBLOX Wiki pages to gain a better understanding
One way you could do is edit the cframe of a player's torso, but I do not know if its no longer a good way, or was one from the start.
local player = game:GetService("Players").LocalPlayer --was the -1 because I forgot this?
local character = player.Character -- you could do player:WaitForChild("Character") or something
local other_platform = Workspace:FindFirstChild("OtherPlatform")
if (other_platform) then
character.Torso.CFrame = other_platform.CFrame * CFrame.new(0, 5, 0) --maybe not a good idea
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
-1?