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

How To Make A Leaderboard Stat A Valid Member Of A Player?

Asked by 7 years ago

So I am attempting to add a line in a script that increases the player's "Cash" by a specific amount but how do I make the script below a valid member of a player?

game.Players.PlayerAdded:connect(function(plr)
    local stats = Instance.new("BoolValue",plr)
    stats.Name = "leaderstats"

    local cash = Instance.new("IntValue",stats)
    cash.Name = "Cash"
    cash.Value = 0
end)

Also, below is the script that I am trying to make give the cash to the player

leave = game.Workspace.leave

workspace.NPC1.Head.Dialog.DialogChoiceSelected:connect(function(player,choice)
    if choice.Name == "Choice1" then            --If the player takes the order
        player.Character.Torso.Anchored = false --Test (does nothing atm)
        game.Players.LocalPlayer.cash.Value = game.Players.LocalPlayer.Cash.Value +5
        wait(3)
        player.Character.Torso.Anchored = false --Test (does nothing atm)
    elseif choice.Name == "Choice2" then        --If the player does not take the order
        player.Character.Torso.Anchored = false --Test (does nothing atm)
        wait(1)
        player.Character.Torso.Anchored = false --Test (does nothing atm)
        script.Parent.Parent.Parent.Humanoid.WalkToPoint = game.Workspace.leave.Position
        wait(5)
        script.Parent.Parent.Parent:Destroy()
    end
end)
0
So, you're trying to make ur first script be in StarterGui or just straight under the player? KingLoneCat 2642 — 7y
0
That script I have in the Workspace. BunnyFilms1 297 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

The stats are within the Bool Value you created in the the first block of script

local stats = Instance.new("BoolValue",plr)
stats.Name = "leaderstats"

and the stat you have created has the bool value as a parent not the actual player itself so instead of:

game.Players.LocalPlayer.cash

it should be

game.Players.LocalPlayer.leaderstats.Cash

and I've noticed some of it is capitalised and some isnt make sure it is correctly capitalised or it wont work.

0
Holy cow! It works! Thank you for taking time out of your day to assist me with my problem! BunnyFilms1 297 — 7y
0
Its fine! Potatofoox 129 — 7y
Ad

Answer this question