So technically this script is supposed to make a screen fade on then make it tp you to a game. Instead it just freezes and crashes, why?
This is the script:
local function RunTP()
while true do
script.Parent.Parent.Parent.Parent.Blackout.Frame.BackgroundTransparency = script.Parent.Parent.Parent.Parent.Blackout.Frame.BackgroundTransparency + 0.2
end
end
script.Parent.MouseButton1Down:Connect(function()
script.Parent.Parent.Parent.Parent.Blackout.Frame.ZIndex = 100
script.Parent.Parent.Parent.Parent.Blackout.Frame.Visible = true
RunTP()
wait(0.5)
script.Parent.Parent.Parent.Parent.Blackout.Frame.Teleporting.Visible = true
game:GetService("TeleportService"):Teleport(5356825192)
end)
If this script would work but theres an easier way, please tell me. All I need is a frame to fade on when you click a button and tp you to a game.
The crash is coming from the second line, the while true do statement.
This is a loop, which means that it will run infinitely. So essentially what youâre doing is you are constantly making the transparency increase by 0.2. The reason this causes a crash is because it is being executed over and over again without yielding (pausing).
Amend it to this:
while script.Parent.Parent.Parent.Parent.Blackout.Frame.BackgroundTransparency < 1 do
script.Parent.Parent.Parent.Parent.Blackout.Frame.BackgroundTransparency = script.Parent.Parent.Parent.Parent.Blackout.Frame.BackgroundTransparency + 0.2
wait()
end
Hence it will only increase transparency until it is maxed, and it will leave a small gap between doing so.
If you want to slow down the fade, increase the number inside the âwait(x)â.
When you execute the RunTP function, it will run a while loop without a wait() and that causes the freeze and crash issue. But one more thing is that you canât be TPed even if you add a wait() because while true loop loop forever so I would suggest tweening the frame or use a for loop.
How would I just make like the screen fall onto the screen (Sorry I am a beginner when it comes to this)
So like a black frame would like âfallâ or slide onto the screen
This will allow you to understand and explore how UIs move across your screen in an effortless fashion. This is relatively advanced programming for Roblox, so if you can master this youâre well on your way to becoming an accomplished scripter
I hope you can experiment with tweening other things that arenât UIs (such as brick transparency etc) that can make some really cool change sequences in your games in the future! Itâs so powerful