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?
Hey Dannzmvp,
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.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.
~~ KingLoneCat