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

Getting player from textbutton?

Asked by 6 years ago

This is my code, I want to obtain the player that clicked the textbutton, but its not working. Help?

function Dialog(player)
    print("Ere")
    if player ~= nil then

        CreateDialog("Are You ok?",player)
        CreateDialog("Oh god, you're bleeding",player)
        CreateDialog("What was that?",player)
    end

end
script.Parent.TextButton.MouseButton1Click:connect(Dialog)
0
Please expand this more I do not understand what you trying to say. PolyyDev 214 — 6y
0
I want to obtain the player who clicked on the textbutton, by using an arguement (player) but it isn't working. GeezuzFusion 200 — 6y
0
TextButton's do not return the player as an argument. Thundermaker300 554 — 6y
0
Is there a way to obtain the player? GeezuzFusion 200 — 6y

1 answer

Log in to vote
0
Answered by
xuefei123 214 Moderation Voter
6 years ago

If this script is a local script, inside the PlayerGui/StarterGui, you can just get the player by doing this:

local player = game.Players.LocalPlayer

Here is an example in your given code:

local player = game.Players.LocalPlayer

function Dialog()
    print("Ere")
    if player ~= nil then

        CreateDialog("Are You ok?",player)
        CreateDialog("Oh god, you're bleeding",player)
        CreateDialog("What was that?",player)
    end

end
script.Parent.TextButton.MouseButton1Click:connect()

Hope this helps, don't forget to accept the answer. It gives us both rep!

0
It isn't what I'm looking for. I want to obtain the player who clicked on the text button by using an argument (player) GeezuzFusion 200 — 6y
Ad

Answer this question