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

GUI Script not working. Textbox will not appear?

Asked by 7 years ago

I recently made this script for my game that I'm currently working on. The script is supposed to make a textbox saying that you earned money appear everytime you click the button. But nothing is working. (BTW, I stripped down a few of the things in the script just for simplicity, so there's no debounce.)

moneyMsg = game.StarterGui.ScreenGui.TextBox button = game.StarterGui.ScreenGui.TextButton moneyMsg.Visible = false

function getMoney() moneyMsg.Visible = true wait(1) moneyMsg.Visible = false end

button.MouseButton1Click:connect(getMoney)

Please help!

0
instead of startergui you should do game.Players.LocalPlayer.PlayerGui, remember that this is happening to the local player only so you should be doing it only to their gui..............startergui is when you want to make changes for all players when they respawn Vulkarin 581 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Main Idea:

You are saying you want a gui to appear saying that you have received money. That is your question, but your script could be so much more simple and look way more professional. (This is to Help for the Gui, not the button, since you didnt provide if the button has a surface gui with a Button, or a Click Detector, either way the script should work.)

Lets Begin

First go into Starter Gui and insert a Screen Gui. Insert a Frame Inside of the Screen Gui. Now insert a Text Box inside of the frame. Inside of the screen gui, insert a Local Script. Before we worry about the code, we will get your Text in the Right position. First change the size of your Frame and Text Box until you are happy with your results. Change the Text inside of the text box to You have received $MoneyNumberHere. Now to get the position of your frame in the center of your screen, change the variables to these {0.5,0},{0.5,0}. Now take the size of your frame, and divide the second number by 2, and the 4th number by 2, and put a negative sign in front of them. example: if my size is

{0,150},{0,200}

then my position would be:

{0.5,-75},{0.5,-100}

now your frame should be dead center.

Now will will learn about the Tween Service. Now, right down the position of your frame then, change the first 0.5 in the position to 10. Now we will finally get into the script.

Lets Define some variables first:

local frame = script.Parent.Frame
local button = game.Workspace.Button
--Add some more here if you are doing more in the script--

Now we will begin working on the main script:

local frame = script.Parent.Frame
local button = game.Workspace.Button
--Add some more here if you are doing more in the script--

function addMoney()
--Lets Work on Tweening--
frame:TweenPosition(UDim2.new(0.5,-75,0.5,-100),'Out','Quint',1)
--The Tween position makes a new tween service, the numbers are where you want to have the frame tween, or animatie to, the out, can be changed with In, its just a different style. The quint can be changed with Bounce,Elastic,Linear and more. The link for the different styles will be at the end. The Number is how long it takes the frame to move to its destination.--
wait(3)
frame:TweenPosition(UDim2.new(10, -75, 0.5, -100),'In','Quint',1)
end

button.MouseButton1Click:Connect(addMoney)


Wiki link to easing styles:http://wiki.roblox.com/index.php?title=API:Enum/EasingStyle

if you need anything else, just comment on my answer.

0
Thanks so much! This was really helpful and my GUI is working very nicely now! I can't give enough thanks! :DD codytron3234 10 — 7y
0
No Problem, It's what I'm here for :D JakePlays_TV 97 — 7y
Ad

Answer this question