What this script does is when you click on a player in a game it brings up a gui, that gui would be the players profile. Only one problem I don't know how to get the players name from the person they clicked.
I tried this but it did not seem to work.
Title.Name = mouse.Target.Parent.Name .. "'s Profile"
The title should appear as "IntellectualBeing's Profile" (Using my name as an example)
wait(1) local plr = game.Players.LocalPlayer; local mouse = plr:GetMouse(); local Frame2 = script.Parent.Content local Title = Frame2.Title mouse.Button1Down:connect(function() if mouse.Target and mouse.Target.Parent and game.Players:GetPlayerFromCharacter(mouse.Target.Parent) then Frame2.Visible = true; Title.Name = mouse.Target.Parent.Name .. "'s Profile" --This does not work. end end)
Sometimes your script would not work because first. What if the mouse target was a part inside a hat? We need to make sure we are getting the character. So this one below should work. Also, I don't think numbers inside variable names will not work.
wait() local plr = game.Players.LocalPlayer; local mouse = plr:GetMouse(); local FrameB = script.Parent.Content --I think numbers in variables wont work. Try letters instead. local Title = FrameB.Title mouse.Button1Down:connect(function() if mouse.Target and mouse.Target.Parent then plr=game.Players:GetPlayerFromCharacter(mouse.Target.Parent) if plr~=nil then FrameB.Visible = true Title.Text = plr.Name .. "'s Profile" --Works now. else plr=game.Players:GetPlayerFromCharacter(mouse.Target.Parent.Parent) if plr~=nil then FrameB.Visible = true Title.Text = plr.Name .. "'s Profile" --Works now. else plr=game.Players:GetPlayerFromCharacter(mouse.Target.Parent.Parent.Parent) if plr~=nil then FrameB.Visible = true Title.Text = plr.Name .. "'s Profile" --Works now. end end end end end)
Edit: What if you hit a hat, Thats double in the input.
(I can't comment on other answers): @1518NICENICKEY: You can have numbers in the variables as long as the number isn't at the beginning of the variable name.
And, I believe you have a great fix for it. Same idea I had when I saw this.
it goes like this
wait(1) local plr = game.Players.LocalPlayer; local mouse = plr:GetMouse(); local Frame2 = script.Parent.Content local Title = Frame2.Title mouse.Button1Down:connect(function() if mouse.Target and mouse.Target.Parent and game.Players:GetPlayerFromCharacter(mouse.Target.Parent) then Frame2.Visible = true; Title.Name = mouse.Target.Parent.Name .. "usernames's Profile" --This does not work. end end)