Hello there. I was making a button that opens another UI when a player clicks it. Then, I would have to reset my character because my code was...
game.StarterGui.ScreenGui..Enabled = true
How would I make the script print the players name?
Full Script
--Varibles local gui = game.StarterGui local plr = game.Players.LocalPlayer --Function function open(plr) gui.NotifyGui.Enabled = true wait(.5) end script.Parent.MouseButton1Click:connect(open)
Hi there! This is actually very simple, So first things first make sure you have the correct function going on! Now here's what the code should look like for the resolved issue!
local gui = game.StarterGui local plr = game.Players.LocalPlayer Gui.MouseButton1Click:connect(function(hit) -- Change Gui, connect it to your own Gui. gui.NotifyGui.Enabled = true print(hit.Parent) --This should print out the Players Name! wait(.5) end)
plr is literally game.Players.LocalPlayer, so to access the name, add the below line
local name = plr.Name --Add after line 7, I'm guessing thats where you want it
Hello. To print the name of the person who clicked you would do this. Hope it helped.
--Variables being used local gui = game.StarterGui local plr = game.Players.LocalPlayer --Function you'd want to use function open(hit) gui.NotifyGui.Enabled = true print(hit.Parent) wait(.5) end script.Parent.MouseButton1Click:connect(hit)