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

I have a problem with TextButtons. Can anyone help?

Asked by 7 years ago

I need help with a TextButton, I already have a code block for making the TextButton Under this text


local screenGui = Instance.new("ScreenGui") screenGui.Parent = script.Parent local textButton = Instance.new("TextButton") textButton.Parent = screenGui textButton.Position = UDim2.new(0, 10, 0, 10) textButton.Size = UDim2.new(0, 170, 0,35 ) textButton.BackgroundColor3 = BrickColor.White().Color textButton.Text = "Spawn" textButton.FontSize = Enum.FontSize.Size18 textButton.MouseButton1Down:connect(function() textButton.Text = "Spawn" end)

There it is, but when I press the button I want it to do something. And now I'm gonna tell you what I want it to do, when I press it I want to remove all GUI's on the screen, then teleport the player that pressed the button and I want to make another GUI "pack" appear. Can I do all that with the press of a TextButton?

0
You can, you just have to properly handle the other GUIs. http://wiki.roblox.com/index.php?title=API:Class/TextButton Coasterteam 4 — 7y
0
It's hard to make a GUI using script. It's easier if you make it's own ScreenGui in StarterGui then script anything you want! Bazuxk 95 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Hey Dannzmvp,

Yes, you can do that all with a textbutton and I will go through each step of what you want your script to do and tell you how to do it but, I will simply tell you what to do, I won't code exactly what you want it to do, that's your job, I will just guide you to the answer.

Removing All Guis

In order to remove all of the guis, you will need to access where all the guis on the screen are stored, "No, duhhhhh". All of the guis in a player are stored inside of the PlayerGui, which is a child of Player. Btw, make sure that this script that you're using to remove all the Guis, isn't located inside of a Gui because, then it might stop working in the middle of it's removal, hence to the script itself being removed. Anyway, that will remove all of the Guis inside of the Player. Now, your question was unclear as to if you also want to remove the CoreGuis, such as: Health, Inventory, TopBar. If you do want to remove those Guis then, go here to learn how to do that. That should be all for removing Guis. Now, let's move on to the next topic.

Teleporting the player

Now, this is where I was a bit confused by your question because, you said the player that clicks the button should be the one to get teleported however, if it's a ScreenGui then only one person can click the Gui, and that is the Client itself. I would understand if it was SurfaceGui because, then many other people could click the Gui since it would be in the Server however, in this case it's just the Client so, you will obviously be using a local script, which you can then use to define who the player is by using LocalPlayer. So, you can identify the player easily like this:

local player = game:GetService("Players").LocalPlayer

After that, you can easily access the Character from the player. Go here to learn about that if you are having trouble.

Making another Gui

I would highly recommend you have the Gui pre-made and then just clone it because, it will save you all the trouble of coding the specific properties for your Gui which can, at times be a pain in the butt. However, once you have your Gui, you can just Parent it to the Player's PlayerGui, hence making another Gui and name it 'pack' or whatever you may want.

Well, I hope I helped in some ways. I hope you sir/ma'am, have a great day/night.

~~ KingLoneCat

0
I have removed the core Guis and i never want them seen :) and thanks for the answer. I'm reading it right now :D Dannzvmp 4 — 7y
0
It was my pleasure. KingLoneCat 2642 — 7y
Ad

Answer this question