GUI Script Help

Introduction

Greetings developers, I’m @ZeronN_Me or better known as TimeNotDesign, I’m still new to this community, but I need help with a problem. :thinking:

The problem

Well, let’s get to the point of this question, so, I’m creating a game, with a theme of levels etc, but, I don’t know how to do these things:

  • Click on a GUI and be redirected to another one (Examples: “Play”, “Settings” and “Credits” buttons and this other GUI’S would be called “Levels”).
  • Within these GUI’S (Levels), by clicking on them, you would be redirected to another game, maybe, in the future, I will need to help with other things with this game, but, this is the problem I have now.

I appreciate any help! :grin:

1 Like

Hello! First of all, I think this fits better in #help-and-feedback:scripting-support but I’m not sure.
Now, for the scripting - first you need to set up a clicked event inside a LocalScript inside the TextButton

script.Parent.MouseButton1Down:Connect(function()
-- do stuff
end)

inside the event, you need to edit the “Visible” property of certain items such as frames -

yourPlayFrameVariable.Visible = true -- the variable would be something like player.PlayerGui.MainGui.PlayFrame
script.Parent.Visible = false -- make the button itself invisible

as for the teleporting - look into this

The end result would look something like this (this wont work as its just an example with random paths and variables):

local TeleportService = game:GetService("TeleportService")
local placeID_1 = 408502340

script.Parent.MouseButton1Down:Connect(function()
   game.Players.LocalPlayer.PlayerGui.MainGui.PlayFrame.Visible = true
   script.Parent.Visible = false
   TeleportService:Teleport(placeID_1, game.Players.LocalPlayer)
end)

Hope this helps and good luck with your games! :grin:

2 Likes

Hello and thanks for helping, but, I have more questions (Don’t need to answer them):

  1. If I want to teleport to another game, do I just need to add your script and the roblox script to my GUI?

  2. If I want to (In the part of clicking on “Play”), how can I make the main GUI (Play) disappear in different ways, like fade or bounce?

No problem!

  1. To teleport to another game, just use another game’s PlaceId
local placeID_1 = 408502340 -- change this number to the place id

This is a PlaceId
image

  1. For that, you need to use TweenService

Example code:

local tweenInfo = local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out, 0, false, 0)
local tween = game:GetService("TweenService"):Create(script.Parent, tweenInfo, {BackgroundTransparency = 1})

TweenInfo has a few parameters which are in this order:

  • Tween length (for example 5) (in seconds)
  • Enum easing style
  • Enum easing direction
  • Repeat count (how many times the tween repeats)
  • Reverses (does the item which is being tweened go back to how it was before the tween)
  • Delay time (how many seconds before the tween starts)

TweenService:Create() has the following parameters:

  • Object to tween (for example that PlayFrame we were talking about)
  • TweenInfo
  • Properties to tween, must be a table (for example: {BackgroundTransparency = 1, BackgroundColor3 = Color3.fromRGB(56, 29, 255)})

Hope I helped :grinning:

1 Like