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

How do you make a transition when you teleport?

Asked by 3 years ago

I'm trying to make a part that teleports you to another room but i don't know how to make a transition screen.

local transitionGUI = game.StarterGui.ScreenGUI.Frame
local ProximityPrompt = script.Parent
ProximityPrompt.Triggered:Connect(function(player)
    transitionGUI.BackgroundTransparency = 0
    wait(1)
    transitionGUI.BackgroundTransparency = 1
    player.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(-190.186, 6.862, -228.86))    
end)

1 answer

Log in to vote
0
Answered by 3 years ago

We can easily achieve the goal you want, by using something called tweening. This can make the GUI look nice, fading in and out. Here:

First off, I'm assuming you put this in a server script because the proximity prompt is the parent of this script. I will write up two scripts, where one goes into the server, and another goes into the client.

--Server script, put this inside of the proximity prompt
local proximityPrompt = script.Parent 
local guiRemote = nil -- here, make a remote event, and where I put nil, locate that remote event
proximityPrompt.Triggered:Connect(function(player)
local char = player.Character
local root = char:WaitForChild("HumanoidRootPart")
root.CFrame = CFrame.new(-190.186, 6.862, -228.86)
guiRemote:FireClient(player)
end)

Now, its time for the client script. Place this script into your frame that you want to transition. For example, game.StarterGui.ScreenGui.Frame

local guiRemote = nil -- once again, locate the remote event here
guiRemote.OnClientEvent:Connect(function(player)
local frame = script.Parent
-- Make sure your frame is big, and takes up the whole screen
frame.Position = UDim2.new(2, 0,0.429, 0)
frame:TweenPosition(
UDim2.new(0,0,0.429,0)
"InOut",
"Linear",
1,
false
end)
-- Now we send the gui back to its original position
wait(1)
frame:TweenPosition(
UDim2.new(2, 0,0.429, 0)
"InOut",
"Linear",
1,
false
frame.Visible = false

if this doesnt work, I can show you tween size, which is more convenient, but for now, try this

Ad

Answer this question