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?
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.
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