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

How To Award people in game if they bought a Game Pass?

Asked by 10 years ago

I want the player clicks (add) to go up to 3 but don't know how. The first script is at... Workspace>Script.

game:GetService("Players").PlayerAdded:connect(function(p)
    if game:GetService("MarketPlaceService"):PlayerOwnsAsset(182358984, p) then
    local add = 3
end)

The second script is at... StarterGui>ScreenGui>TextButton>LocalScript. This second script works fine so don't do anything to it I just need the first script to make the number per click go up ONLY FOR THAT PERSON THAT BOUGHT IT.

local number = 0
local add = 1
script.Parent.MouseButton1Click:connect(function()
    number = number + add
    script.Parent.Parent.TextBox.Text = "".. number
end)

1 answer

Log in to vote
0
Answered by 10 years ago

Okay, you have a few problems here.

First off, you have the parameters for the :PlayerOwnsAsset() incorrect. The player comes first, then the Asset ID.

Also, you have a very inefficient way of adding points to the person with the gamepass. I'm not sure if it would even work.

Here is the changed code, explained in comments:

local player = game.Players.LocalPlayer --assuming it is a LocalScript, which it should be to work

script.Parent.MouseButton1Click:connect(function() --connect directly to the mouseclick
    if game:GetService("MarketPlaceService"):PlayerOwnsAsset(player,182358984) then
    number = 0
    number = number + 3
    script.Parent.Parent.TextBox.Text = number --you don't need the quotation marks if there is no content to it.
    else
    number = 0
    number = number + 1
    script.Parent.Parent.TextBox.Text = number
   end
end)

That should work, assuming the whole points of this is to add points only if they own the gamepass.

0
There is an error on line 4 on Studio. raystriker6707 30 — 10y
0
Try now, forgot an end, sorry. SlickPwner 534 — 10y
Ad

Answer this question