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

Find player when they click on a SurfaceGUI

Asked by 10 years ago

I'm trying to make a script in which when you click on a SurfaceGUI button, it makes the "box" belong to that player. To do this I need to change some values to equal the player's name. The only problem is finding the player. I'm not sure how to find the player after clicking (You might've seen my (player) After the function, that was me trying to find it). Anyway can someone please help? Here's the script:

boxsettings = script.Parent
frame = script.Parent.Parent
bin = script.Parent.Parent.Parent

boxsettings.MouseButton1Click:connect(function(player)
    if boxsettings.Text == "Claim Box!" then
        boxsettings.Text = "Box Settings"
        frame.Owner.Value = player.Name
        frame.CurrentOwner.Text = "Current owner: "..player.Name
    end
end)

3 answers

Log in to vote
0
Answered by 10 years ago

I suppose you do not wish to make these GUIs local (Meaning that if you change the text, other players would not be able to see changes made to them)

In that case it is not possible to get the player from a click on the button.

Your only option would be to make a local script that checks if the player clicks on the part the surfacegui is in and then changes it to the name.

Ad
Log in to vote
1
Answered by 10 years ago

'SurfaceGuis must be descendants of PlayerGui in order to know the player who is interacting with it.'

Have you done that ?

Log in to vote
0
Answered by 10 years ago

Alright thanks a lot everyone. Your information really helped.

Answer this question