Attempting to give item through dialogue, but script isn't working

I’m trying to give a player a simple slice of pizza through dialog. The item in the workplace is named ‘Pizza’. I’ve used this script but it doesn’t seem to be working. What am I doing wrong?

local rs = game:GetService(‘ReplicateStorage’)
local Latte = rs:WaitForChild(‘Pizza’)

script.Parent.DialogChoiceSelected:connect(function(player, Dialog)
if Dialog.Name == ‘Dialog A’ then
if player.Backpack:FindFirstChild(‘Pizza’)== nil then
Latte:Clone().Parent = player.Backpack
end
end

end)

1 Like

What exactly is “DiaogChoiceSelected”. If it’s a RemoteEvent, you forgot the .OnServerEvent

2 Likes

You should use :Connect as :connect is deprecated.

Have you tried printing anything inside of the event to see if the event is working?

I uppercased Connect, but still not working.
What do you mean by printing?

Adding print('dialog worked') or something like that and checking the output.

I used this script from what I’ve found online, I assumed DialogChoiceSelected refered to the dialog. Also, where should I input .OnServerEvent?

You misspelled ReplicatedStorage on line one.

2 Likes

Thank you all, I think I’ve found a solution:

local rs = game:GetService('ReplicateStorage')
local Latte = rs:WaitForChild('Pizza')
local remote = rs:WaitForChild("Remote")

script.Parent.DialogChoiceSelected:connect(function(player, Dialog)
    if Dialog.Name == 'Dialog A' then
        if not player.Backpack:FindFirstChild('Pizza') then
            remote:FireServer(Latte)
        end
    end

end)