Need help with my ordering system

Hello,

  1. What do you want to achieve? Keep it simple and clear!
    I have created a system where the customer orders an object and then goes to pick it up.

  2. What is the issue? Include screenshots / videos if possible!
    When the NPC order something, it store the order in a string value. It supposed to give him the item that he ordered if I have it equipped and if the item name match with the value stored in the string value.
    But it dosen’t, even if the item name and the value are the same…
    At line 20, it tell me what item I have equipped and at line 22, the npc order. But instead of giving him the item, it execute the “else” in the script.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have try to search on google, but I haven’t found anything.

local destination = game.Workspace.System_PNJ.Delete
local SC = game.Workspace.System_Commande
local PathfindingService = game:GetService("PathfindingService")

local EC = game.Workspace.EcranCommande.Ecran
local D = true

script.Parent.Client.Touched:Connect(function(touchie)
	local Cha = touchie.Parent
	local Hum = Cha.Humanoid
	if touchie.Parent.Name == "Customer" and D == true then
		D = false
		script.Used.Value =true
		script.Parent.Ecran.Order.Enabled = true
		
		script.Parent.Ecran.Order.Triggered:Connect(function(plr)
			local PN = plr.Name
			local IH = plr.Character:FindFirstChildOfClass("Tool")
			print(IH) --Line 20
			local PNJ_Item = Cha.PNJ_Data.Commande.Value
			print(PNJ_Item) --Line 22
			if PNJ_Item == IH then
				IH:Destroy()
				Hum.DisplayName = "Thanks!"
				local V = Cha.PNJ_Data.NumeroCommande.Value
				script.Parent.SurfaceGui.ScrollingFrame[V]:Destroy()
				local path = PathfindingService:CreatePath()
				Hum:MoveTo(destination.Position) 
				wait(0.5)
				D = true
				script.Used.Value = false
				Hum.MoveToFinished:Wait()
			else
				local DN = Hum.DisplayName
				Hum.DisplayName = "I haven't ordered that!"
				wait(3)
				Hum.DisplayName = DN
			end
			
		end)
	end
end)

help

If someone know how to fix this, your welcome…
Thanks.

1 Like

try replacing

if PNJ_Item == IH then

with

if PNJ_Item == IH.Name then

This might help

2 Likes