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

Is this script Modifiable to a different leaderboard? If so how can I change it?

Asked by 9 years ago

Basically what the title says I'm looking to change the leaderboard that this script uses because I tried fixing it my self It's not fixable to my knowledge sadly... This is the original script no edits.

--Services--
    local Players = game:GetService("Players")
    local ReplicatedStorage = game:GetService("ReplicatedStorage")

--Variables--
    local Player = Players.LocalPlayer
    local PlayerGui = Player.PlayerGui
    local LeaderStats = Player:FindFirstChild("leaderstats")
    local RequestLeaderboardChangeMaster = game.ReplicatedStorage.RequestLeaderboardChange
    local Backpack = Player:FindFirstChild("Backpack")
    local StarterGear = Player:FindFirstChild("StarterGear")
    local SurfaceGui = ReplicatedStorage:FindFirstChild("Shop", true):Clone()
    SurfaceGui.Parent = PlayerGui
    local mouse = Player:GetMouse()

    local ItemsForSale = {
        ["Sword"] = {
            ["Cost"] = 10;
            ["Currency"] = "Tickets";
        },
        ["Sword2"] = {
            ["Cost"] = 20;
            ["Currency"] = "Tickets";
        },
        ["Sword3"] = {
            ["Cost"] = 30;
            ["Currency"] = "Tickets";
        }
    }

    local ItemNames = {"Sword","Sword2","Sword3"}

local function UpdateShopTarget()
    if mouse.Target then
        if mouse.Target.Name == "Shop" then
            SurfaceGui.Adornee = mouse.Target
        else
            SurfaceGui.Adornee = nil
        end
    else
        SurfaceGui.Adornee = nil
    end
end

local function GetMoney(Currency)
    local IntValue = LeaderStats:FindFirstChild(Currency)
    if IntValue then
        return IntValue.Value
    end
    return 0
end

local function SubtractMoney(Currency, Amount)
    local LeaderboardChangeObject = RequestLeaderboardChangeMaster:clone()
    local valueToUpdate = Instance.new("IntValue")
    valueToUpdate.Name = Currency
    valueToUpdate.Value = GetMoney(Currency) - Amount
    valueToUpdate.Parent = LeaderboardChangeObject.RequestedValues
    LeaderboardChangeObject.playerName.Value = Player.Name
    LeaderboardChangeObject.Parent = game.Workspace
end

local function AwardItem(ItemName)
    local Item = ReplicatedStorage.Weapons:FindFirstChild(ItemName)
    if Item then
        Item = Item:Clone()
        Item.Parent = Backpack

        Item = Item:Clone()
        Item.Parent = StarterGear
    end
end

--SurfaceGui Pre-initialization--
local Window = SurfaceGui:FindFirstChild("Window")
local ProtoButton = SurfaceGui:FindFirstChild("ProtoButton")
for i=1, #ItemNames do
    newButton = ProtoButton:clone()
    newButton.Name = ItemNames[i]
    newButton.Position = UDim2.new(0,22,0,100*i)
    newButton.Active = true
    newButton.Visible = true
    newButton.Parent = Window
end

Window.CanvasSize = UDim2.new(1,0,0,100+100*#ItemNames)

--SurfaceGui Variables--
local ArrayOfChildren = Window:GetChildren()

for _, Button in pairs (ArrayOfChildren) do
    local ItemName = Button.Name
    --print("Got button", ItemName)
    local ItemAttributes = ItemsForSale[ItemName]
    if ItemAttributes ~= nil then
        --print("Got data for", ItemName)
        local Cost = ItemAttributes["Cost"]
        local Currency = ItemAttributes["Currency"]
        --print("   ", "Cost:", Cost)
        --print("   ", "Currency:", Currency)
        Button.Text = ItemName..": "..Cost.." "..Currency
        Button.MouseButton1Click:connect(function()
            if LeaderStats then
                if GetMoney(Currency) >= Cost then
                    SubtractMoney(Currency, Cost)
                    AwardItem(ItemName)
                end
            end
        end)
    end
end

--Connection event to map the Shop GUI onto whatever the mouse is hovering on (provided it's named "Shop")
mouse.Move:connect(UpdateShopTarget)
0
What exactly are you trying to change it to? dyler3 1510 — 9y
0
I'm trying to change it to a simple leaderboard then the one it's using. But I don't know how it can be done? Anciteify 70 — 9y

Answer this question