tycrate1
(Tycrate1)
November 4, 2020, 1:42am
#1
I am trying to figure out what player clicked the UI button, I am using MouseButton1Up, I am also using GetPlayerFromCharacter to get the player but i need in the () what clicked the button
I am trying to pop up the purchase premium UI but I don’t know what player clicked the button
I have looked it up I found a post similar but I didn’t find it useful to my topic
If it is a gui element then the person that clicked the button will be always game.Players.LocalPlayer
7 Likes
tycrate1
(Tycrate1)
November 4, 2020, 3:22am
#3
I find that that is not working for me for some reason here is some of the code
premiumBuy.MouseButton1Up:Connect(function()
local player = game.Players.LocalPlayer
print(player)
I have also tried
premiumBuy.MouseButton1Up:Connect(function()
local player = players:GetPlayerFromCharacter(game.Players.LocalPlayer)
print(player)
it prints nil for the player both ways
Is this a script? If it is a script then it will always print nil. Try that in a local script
1 Like
Blaroo
(rak)
November 4, 2020, 11:51am
#5
Don’t use scripts for GUIs, use local scripts, just remember that LocalPlayer doesn’t work in scripts, it will always print in serverside.
tycrate1
(Tycrate1)
November 4, 2020, 2:29pm
#6
oh ok thankyou, Lol I didn’t even notice I used a script and not a local script
1 Like
dkdntgn
(Unknown)
May 22, 2022, 11:15am
#7
if you want to do this on the server side then do it with RemoteEvent
how would this be done using a Server Sided Script for surface guis? i understand this may not be recommended but it is more efficient for my script
is there any more efficient ways that doesent require communicating to the client?