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

SOLVED: Trying to make a Gui to give a player a gui from lighting, Anyone can help?

Asked by 4 years ago
Edited 4 years ago

I've made a Gui which is kept in game.Lighting area. This Gui kills the player once they get given it, soo I don't want to put it in startergui. I'm trying to make a Gui which will have a textbox to type a players name, and a box to give that player the Gui. So it's a bit like a hand tool to player gui but instead it is a clone Gui from lighting and give to player Gui. One thing I'm stuck on is actually making the script to give the player the gui once I entered their name and pressed the button. Could anyone help?

2 answers

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

I got what you want to do. Here's what you should do: (Script)

local textbox = 'TEXTBOX HERE!! with script.Parent blah blah'
local button = 'BUTTON HERE... Same thing like textbox'
local gui = 'GUI PATH HERE'

button.MouseButton1Click:Connect(function()
    local clone = gui:Clone()
    clone.Parent = game.Players:WaitForChild(textbox.Text).PlayerGui
end)

Try this and answer with the result.

0
That's not going to work... proqrammed 285 — 4y
0
It does work. Try it yourself. Made a small fix about it cloning inside the player instead of playergui. lolol1901 28 — 4y
0
Yep, you fixed it. Mine works too by the way. proqrammed 285 — 4y
0
Hey, Thank you for the help! The script worked perfectly and is easy to understand how it works. Thank you! kyloren528 11 — 4y
View all comments (2 more)
0
No problem. Come to me if you have any problems again by just replying to this comment with the link to your question. lolol1901 28 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Hello!

Note: Tested this and it works. If there is something you'd like me to change please comment and if this helps please accept this answer as correct because I put in quite some effort making this nice. The script is long because I use a lot of comments to explain what each line does. Thanks!

This script will check the text in the textbox, then will clone the gui from Lighting into the player with the name in the textbox's gui then disable the old one. On with the script and explanation:

First of all, it used to be a habit of mine too, but you shouldn't use Lighting to store things, just so you know. You can use it for this though if you'd like. For this, you will need to use a localscript (in a button) to bring in the other gui. This goes in the local script:

--VARIABLES--
    local OtherGui = ... --choose your directory, change this to whatever it actually is
    local CurrentGui = ... --same thing, this is the frame that the button is in right now
    local textbox = ... --the text box
    local playerToCloneTo = game.Players:WaitForChild(textbox.Text)

--FUNCTION--

function leftClick()
    print("Button clicked!")
    local OtherGuiClone = OtherGui:Clone()
    OtherGuiClone.Parent = playerToCloneTo.PlayerGui --put in the player's gui
    CurrentGui.Visible = false -- disable current gui, (optional or change however you want)
end

script.Parent.MouseButton1Click:Connect(leftClick)

Hope this helps! Happy holidays :D

0
Hey, This script also worked! Thank you for the help, I'll try and start using other stuff to store things, thanks for the advice! Happy Holidays! kyloren528 11 — 4y
0
Pro tip: mark you problem as solved in the title so that people know this is closed and solved. proqrammed 285 — 4y

Answer this question