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

Any one who can help me with this PlayerPoint scriping problem i'm having?

Asked by 10 years ago

Okay so for this script, I want it so the first time a player joined the game they get 1 PlayerPoint I have that down. I want the script where when you buy PlayerPoints it makes your KO's go up In-game and you well, get the player points. Any helpers?

Heres the script

local plr = script.Parent.Parent.Parent
local link = game:GetService("MarketplaceService")
local y = 75 
local statn = "KOs" -- this is like leaderboard

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 = 19254314, points = 50, cost = 4, nam = "Add Player Points"};
    {id = 19254314, points = 100, cost = 8, nam = "Add Player Points"};
    {id = 19254314, points = 150, cost = 12, 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 = "Sh0p";
    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 = "beta";
    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)

local service = game:GetService("PointsService") 

game.Players.PlayerAdded:connect(function(player) 
player:WaitForDataReady() 
service:AwardPoints(141403485, service:GetAwardablePoints()) 
end) 


local PointsService = Game:GetService("PointsService")


game.Players.PlayerAdded:connect(function(player)

    local pointsToAward = PointsService:GetAwardablePoints()

    local universeBalance = PointsService:GetGamePointBalance(player.userId)

    if ( pointsToAward > 0 and universeBalance == 0) then

        pcall(function()
            PointsService:AwardPoints(player.userId, 1)
        end)
    end
end)


PointsService.PointsAwarded:connect(function(userId, userBalanceinUni, userBalance)

    local message = Instance.new('Message', game.Workspace)
    message.Text = "Point awarded to " .. userId .. ". This player now has " .. userBalance .. " points total!"
    wait(5)
    message:Destroy()
end)

I have tried just it's kinda difficult at the moment, anyone who can help?

Answer this question