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

Why won't the dialog shop work?

Asked by 8 years ago

This dialog shop won't work...

local dialog = script.Parent
dialog.DialogChoiceSelected:connect(function(player, choice)
    -- Check the player has a stats object
    local stats = player:FindFirstChild('leaderstats')
    if not stats then return end

    -- And that the stats object contains a gold member
    local gold = stats:FindFirstChild('Points')
    if not gold then return end

    if choice == script.Parent.DialogChoice.ChoiceA then
        if gold.Value >= 50 then -- 5 is the amount of gold you need to purchase this weapon
            game.ServerStorage.Weapon1:Clone().Parent = player.Backpack
            gold.Value = gold.Value - 50 -- subtract the amount of gold you need to purchase
        end
    elseif choice == dialog.DialogChoice.ChoiceB then
        if gold.Value >= 85 then
            game.ServerStorage.Weapon2:Clone().Parent = player.Backpack
            gold.Value = gold.Value - 85
        end
    elseif choice == dialog.DialogChoice.ChoiceC then
        if gold.Value >= 115 then
            game.ServerStorage.Weapon3:Clone().Parent = player.Backpack
            gold.Value = gold.Value - 115
    elseif choice == dialog.DialogChoice.ChoiceD then
        if gold.Value >= 200 then
            game.ServerStorage.Weapon4:Clone().Parent = player.Backpack
            gold.Value = gold.Value - 200
    elseif choice == dialog.DialogChoice.ChoiceE then
        if gold.Value >= 270 then
            game.ServerStorage.Weapon5:Clone().Parent = player.Backpack
            gold.Value = gold.Value - 270
        end
    end
end
end
end)

Answer this question