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

How do I make a character that gives an item after a dialog?

Asked by
Tyler8D -5
4 years ago
Edited 4 years ago

I've been trying to make "shop dialogs" and I followed this roblox tutorial https://developer.roblox.com/articles/Shop-Dialogs but it does not work. The tutorial is very recent so i'm assuming my code is incorrect somehow. If someone could help me figure out what I did wrong that would be great.

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 scoobysnacks = stats:FindFirstChild('Scoobysnacks')
if not scoobysnacks then return end

if choice == script.Parent.DialogChoice.ChoiceA then
    if scoobysnacks.Value >= 5 then -- 5 is the amount of gold you need to purchase this weapon
        game.ReplicatedStorage.Weapon1:Clone().Parent = player.Backpack
        scoobysnacks.Value = scoobysnacks.Value - 5 -- subtract the amount of gold you need to purchase
    end
elseif choice == dialog.DialogChoice.ChoiceB then
    if scoobysnacks.Value >= 10 then
        game.ReplicatedStorage.Weapon2:Clone().Parent = player.Backpack
        scoobysnacks.Value = scoobysnacks.Value - 10
    end
elseif choice == dialog.DialogChoice.ChoiceC then
    if scoobysnacks.Value >= 15 then
        game.ReplicatedStorage.Weapon3:Clone().Parent = player.Backpack
        scoobysnacks.Value = scoobysnacks.Value - 15
    end
end

end)

Edit: Probably should have specified the main problem I have been having is that after the dialog ends I do not receive an item like i'm supposed to.

0
did you get errors? ReallyUnikatni 68 — 4y
0
The main problem I have been having is that after the dialog ends I do not receive an item like i'm supposed to. Tyler8D -5 — 4y

Answer this question