Does anyone know how i can get the Player using a Server Script when players click a Button? Btw the Script is in a Surface GUI in WorkSpace script.Parent.MouseButton1Click:Connect(function()
MarketplaceService:PromptGamePassPurchase(Plr, GamepassId)
end) (i need the Player)
I recommend using ClickDetectors instead, they’re much easier to use for serverside operation.
2 Likes
Hey, for a SurfaceGui having a textbutton, you can put a LocalScript inside StarterPlayerScripts. This allows us to just use game.Players.LocalPlayer
to get the player.
local mps = game:GetService("MarketplaceService")
local GamepassId = 0
local plr = game.Players.LocalPlayer
local Button = game.Workspace:WaitForChild("Part").SurfaceGui.TextButton
Button.MouseButton1Click:Connect(function()
mps:PromptGamePassPurchase(plr, GamepassId)
end)
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.