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

Player Point Script? [Unsolved]

Asked by 10 years ago

How would you change this script, so if you buy the Dev Product you get a Darkheart or Illumina?

local plr = script.Parent.Parent.Parent
local link = game:GetService("MarketplaceService")
local y = 75 -- 300( the frame's Y Size offset) /# of buttons you want. -> 300/4 = 75
local statn = "KOs" -- stat name here

local function create(instanc)
    return function(object)
        local button = Instance.new(instanc)
        for i,v in pairs(object) do 
            button[i] = v
        end
        return button
    end
end




repeat wait() until plr:findFirstChild("leaderstats")
local stat = plr.leaderstats[statn]


local conversions = 
{
    {id = 19793144, points = 0, cost = 1, nam = "Add 100 Player Points"};
    {id = 19740656, points = 0, cost = 1, nam = "Add Player Points"};
    {id = 19740656, points = 0, cost = 1, nam = "Add Player Points"};

}


local main = create("Frame")
{
    Size = UDim2.new(0, 250, 0, 0);
    BackgroundTransparency = 1;
    ZIndex = 3;
    Position = UDim2.new(0,-250,.5,-165);
    Name = "Shop";
    Parent = script.Parent
}

local folder = create("Frame")
{
    Size = UDim2.new(0,200,0,300);
    BackgroundColor = BrickColor.new("Really black");
    BackgroundTransparency = .3;
    Active = true;
    ZIndex = 2;
    Parent = main

}

local header = create("Frame")
{
    Size = UDim2.new(.5,0,0,20);
    Position = UDim2.new(1,0,0,0);
    Name = "ShopHeader";
    BackgroundTransparency = 1;
    ZIndex = 3;
    Parent = main
}

local Tbutton = create("TextButton")
{
    Size = UDim2.new(0,20,0,20);
    Position = UDim2.new(1,3,0,0);
    BackgroundTransparency = .25;
    BackgroundColor = BrickColor.new("Really black");
    ZIndex = 3;
    BorderSizePixel = 0;
    Text = ">>";
    TextColor = BrickColor.White();
    Parent = header

}

local label = create("TextLabel")
{
    Text = "Shop";
    Size = UDim2.new(1,0,0,20);
    BackgroundTransparency = .25;
    BackgroundColor = BrickColor.new("Really black");
    ZIndex = 3;
    BorderSizePixel = 0;
    TextColor = BrickColor.White();
    Font = "Legacy";
    FontSize = "Size12";
    Parent = header

}

local watermark = create("TextLabel")
{
    Size = UDim2.new(0,0,0,0);
    Position = UDim2.new(1,0,1,0);
    TextXAlignment = "Right";
    TextYAlignment = "Bottom";
    BackgroundTransparency = 1;
    ZIndex = 3;
    TextColor = BrickColor.new("Institutional white");
    Font = "Legacy";
    FontSize = "Size10";
    Text = "GUI";
    TextTransparency = .9;
    Parent = folder

}

local function buyItem(button)
    button.MouseButton1Click:connect(function()
        local marketId = button["market"].Value
        local pointsToAward = button["points"].Value
        link:PromptProductPurchase(plr,marketId) 
        link.ProcessReceipt = function(receiptInfo)
            if Enum.ProductPurchaseDecision.PurchaseGranted and receiptInfo.PlayerId == plr.userId then
                stat.Value = stat.Value + pointsToAward
            end
        end
    end)
end

for i,v in ipairs(conversions) do 
    local button = create("TextButton")

    {
        Size = UDim2.new(1,0,0,y);
        BackgroundColor = BrickColor.Black();
        TextColor = BrickColor.White();
        TextXAlignment = "Left";
        FontSize = "Size14";
        Position = UDim2.new(0,0,0,((i*y)+2)-(y+2));
        BorderSizePixel = 0;
        Font = "Legacy";
        Text = v.nam;
        ZIndex = 3;
        Parent = folder

    }

    local cost = create("TextLabel")

    {
        Size = UDim2.new(0,0,1,0);
        BackgroundColor = BrickColor.Black();
        TextXAlignment = "Right";
        FontSize = "Size14";
        Position = UDim2.new(1,0,0,0);
        BorderSizePixel = 0;
        TextColor3 = Color3.new(20/255, 166/255, 0/255);
        Text = v.cost.."R$";
        ZIndex = 3;
        Parent = button

    }

    local buyTag = create("IntValue")

    {
        Name = "market";
        Value = v.id;
        Parent = button;

    }

    local pointsTag = create("IntValue")

    {
        Name = "points";
        Value = v.points;
        Parent = button;

    }

    buyItem(button)

end


local gui = main
Tbutton.MouseButton1Click:connect(function()
    if Tbutton.Text == ">>" then
        gui:TweenPosition(UDim2.new(0,0,.5,-165), "Out", "Back", true,.5)
        header:TweenPosition(header.Position - UDim2.new(0,45,0,0), "In", "Quad", true)
        Tbutton.Text = "<<"
    else
        gui:TweenPosition(UDim2.new(0,-250,.5,-165), "Out", "Quad", true,.5)
        header:TweenPosition(UDim2.new(1,0,0,0), "In", "Quad", true)
        Tbutton.Text = ">>"
    end
end)

1 answer

Log in to vote
0
Answered by 10 years ago

Line 4, It should be local stat = "KOs" -- stat name here

Ad

Answer this question