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

How to make a NPC give items using leaderboard cash?

Asked by 6 years ago
local dialog = script.Parent
dialog.DialogChoiceSelected:connect(function(player, choice)
    local stats = player:FindFirstChild('leaderstats')
    if not stats then return end

    local old = stats:FindFirstChild('Cash')
    if not Cash then return end

    if choice == script.Parent.DialogChoice.ChoiceA then
        if Cash.Value >= 500 then 
            game.ReplicatedStorage.Weapon1:Clone().Parent = player.Backpack
            Cash.Value = Cash.Value - 500 
        end

I want this script to give a "Bat" when you speak to it and have enough money. I have this script and its inside the NPC's head any suggestions: Here are some more screenshots of what i've done:

https://gyazo.com/209d495e015dbdb196a63d29b9c62455

https://gyazo.com/89ee2978f88f78b78c5e5c6e5984637d

1 answer

Log in to vote
0
Answered by 6 years ago

Line 6's variable name is old, but you then use Cash on line 7.

If you open up the Script Analysis window in Roblox Studio, it will tell you when you use variables that aren't defined elsewhere.

Ad

Answer this question