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

Help with getting player.Name from button push from normal script?

Asked by 3 years ago

Ok even if I knew how to get player who clicked a textbutton from a normal script, i wouldnt know how to use that name to show it on all clients. Is there a way to carry a value (like a player name) to another script? (Specifically server to local all clients) I need help with these 2 things? script.Parent.MouseButton1Click:Connect(function(player) print(player.Name) end) Would this work? Also if it does how do i carry that player.Name value to a local script for all clients after firing a remote event? I would appreciate some help because im stumped

1 answer

Log in to vote
0
Answered by 3 years ago

Ok, MouseButton1Down doesn't return any values, so the player parameter in your script is nil. Before you ask why, I don't know why; I think it is stupid.

To fix the script would need to find how many parents the script has until you reach the screengui. (Example: script > textbutton > frame > screengui = 3) Then, in your script you would add 2 more parents. All gui's go into PlayerGui, which is sent into the player object. Your script would look like this:

script.Parent.MouseButton1Click:Connect(function() 
     print(script.Parent.Parent.Parent.Parent.Parent.Name) --Using the same example above
end)

(Just a bit of a sidenote: when asking questions here, be sure to use the "Code Block" button and not the "Inline code" when writing Lua Scripts)

I hope this answers your question.

0
Im gonna try this, i also think i know how to bring the name to the local script. (String value) i’ll let you know if this works! Thanks by the way AngryPlaayer 17 — 3y
0
This works!!!!! Thank you so much. I’m having some more problems but I can handle it! Thank you so much AngryPlaayer 17 — 3y
Ad

Answer this question