My NPC's won't give items that people want, even when they have the required KOs (1), the script is a LocalScript, the items are inside ReplicatedStorage - Game_Tools - Food, and the NPC is inside the Workspace. The script looks okay, but I'm confused why it won't work. It doesn't even remove 1 KO to give you the item. No errors either.
local function select(p,d) local ko = p.leaderstats.KOs if ko.Value >= 1 then ko.Value = ko.Value - 1 local item = game.ReplicatedStorage.Game_Tools.Food:findFirstChild(d.Name) local new = item:clone() new.Parent = p.Backpack end end script.Parent.DialogChoiceSelected:connect(select)
Try if this works, I'm a noob myself.
local function select(p,d) local ko = player.leaderstats.KOs local item = game.ReplicatedStorage.Game_Tools.Food local player = script.Parent.Parent.Parent.Parent -- change the final Parent to Workspace. if ko.Value >= 1 then ko.Value = ko.Value - 1 item:Clone().Parent = player.Backpack end end script.Parent.DialogChoiceSelected:connect(select)
local function select(p,d) local item = game.ReplicatedStorage.Game_Tools.Food local player = game.Players.LocalPlayer --Add ".Character" if it is what you needed local ko = player.leaderstats.KOs if ko.Value >= 1 then ko.Value = ko.Value - 1 item:Clone().Parent = player.Backpack end end script.Parent.DialogChoiceSelected:connect(select)