Hi, I’m making a donation board but I’m not sure how to get the player when they press a button.
How to get player from MouseButton1Click on server?
for _, data in ipairs(ProductsData.Products) do
local newButton = script.Content.BuyProductButton:Clone()
newButton.Text = data.ProductPrice .. " Robux"
newButton.Parent = script.Parent.Parent.BuyProduct.SurfaceGui.ScrollingFrameBuy
end
You don’t and you’re not supposed to. Interactable SurfaceGuis are intended to be parented to the PlayerGui and adorned to the part in question. See the note on the documentation page.
Use a LocalScript if you need to handle input on the Gui and RemoteEvents if the server needs to be involved in any way, whether to sync data to other clients or to update something server-side. If you need the player for a LocalScript, LocalPlayer exists.