Is dialog item giver still work in 2021 using a script?

I recently made a script and watched a lot of tutorials about dialog givers, but they seem that they need FE disabled and something about remote events which I am absolutely unfamiliar with.

local rs = game.GetService('ReplicatedStorage')
local Toaster = rs:WaitForChild('Toast')

script.Parent.DialogChoiceSelected:Connect(function(player, Dialog)
	if Dialog.Name == 'Dialog' then
		if player.Backpack:FindFirstChild('Toast') == nil then
			Toaster:Clone().Parent = player.Backpack
		end
	end

end)

Something like this. Also i remember one game include it for a cost: ROBLOX NPCs are becoming smart! (52nd ENDING!) - Roblox

The replies at Dev forum also don’t work, including Dev Articles. They “had” a shop dialogs article, but it was removed or something. So I am wondering, should i create shops without dialogs now? Or just going and creating remote function script?

Apologies if text is too small.

According to developer documentation the event is client-side only and wont fire on the server, therefore attempting to listen to it from a Script does not work. Instead create a LocalScript which fires a remote on DialogChoiceSelected that gets picked up from a Script which parents the tool:

--Script inside ServerScriptService
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Toaster = ReplicatedStorage:WaitForChild("Toast")
local Remote = Instance.new("RemoteEvent", ReplicatedStorage) 
Remote.Name = "ChatRemote"

function HasTool(player, name) 
	local case1 = (player.Backpack and player.Backpack:FindFirstChild(name))
	local case2 = (player.Character and player.Character:FindFirstChild(name))
	--if the tool is found inside their character or backpack, they have it
	return (case1 or case2)
end

Remote.OnServerEvent:Connect(function(player)
	if not HasTool(player, Toaster.Name) then 
		Toaster:Clone().Parent = player.Backpack
	end
end)
--LocalScript inside StarterCharacterScripts
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--path to dialog
local Dialog = workspace.Dummy.Head.Dialog 

local Toaster = ReplicatedStorage:WaitForChild("Toast")
local Remote = ReplicatedStorage:WaitForChild("ChatRemote") 

Dialog.DialogChoiceSelected:Connect(function(player, Dialog)
	if Dialog.Name == "Dialog" then
		Remote:FireServer()
	end
end)
1 Like

Wow thank you so much! Now toaster is working fine!

1 Like

I would also add more dialog shops into the game, but it always gives the same tool. What should I rename/make so it will work?

Remote:FireServer("toolName") 

and

local tools = {
	["Toast"] = Toaster,
	["Tool2"] = Tool2Path,
	["Tool3"] = Tool3Path
	--etc.
}

Remote.OnServerEvent:Connect(function(player, toolname)
	local tool = tools[toolname]
	if tool and not HasTool(player, toolname) then 
		tool:Clone().Parent = player.Backpack
	end
end)

I tried to fire the script but It got messed up completly.

I am also trying to do the same thing and have different tools for different dialog choices. I tried implementing the second script you posted but it didn’t work. I’m not sure how the game is supposed to know what dialog choice is related to what tool, so I added a different LocalScript for each tool with their respective dialog choice paths and tool paths but it still didn’t work. This is what I did:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Toaster = ReplicatedStorage:WaitForChild("Toast")
local Remote = Instance.new("RemoteEvent", ReplicatedStorage) 
Remote.Name = "ChatRemote"

local tools = {
	["Toast2"] = ReplicatedStorage:WaitForChild("Toaster2"),
	["Toast"] = Toaster

}

Remote.OnServerEvent:Connect(function(player, toolname)
	local tool = tools[toolname]
	if tool(player, toolname) then 
		tool:Clone().Parent = player.Backpack
	end
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--path to dialog
local Dialog = workspace.Dummy.Head.Dialog

local Toaster2 = ReplicatedStorage:WaitForChild("Toast2")
local Remote = ReplicatedStorage:WaitForChild("ChatRemote") 

Dialog.DialogChoiceSelected:Connect(function(player, Dialog)
	if Dialog.Name == "Choice2" then
		Remote:FireServer("toolName")
	end
end)