Tool/Quest NPC System Paying (350 Robux)

its not even done right, i dont want it coming from the client side.

1 Like

its not even done right, i dont want it coming from the client side.

doing that on the server is inefficent and harder you have to do it on the client. though if you want to tell the server that player X has done the task, you basically add a RemoteEvent in the ReplicatedStorage and then fire it.

1 Like

yeah but you are looking for payment but the way i want it is when the players join they can all help with the one quest which is server sided and the tool even should be client sided where it interacts with the model from the client side.

1 Like

If you want the serverside then create a script in the ServerScriptServer then add this:

--local player = game:GetService("Players").LocalPlayer --The Player
local billboard = workspace:WaitForChild("NPC"):WaitForChild("BIllboard"):FindFirstChild("BillboardGui") --The Billboard
local clickDetector = workspace:WaitForChild("NPC"):WaitForChild("ClickDetector") --The ClickDetector

local objstate = { -- The state of the object
	false,
	false,
	false,
}

local Objects = { -- The objects
	"Engine",
	"Battery",
	"Tire",
}

local function CheckItems(player :Player)
	
	for i,v in ipairs(objstate) do
		
		if v == false then
			--local Value = player.Backpack:FindFirstChild(Objects[i]) or player:FindFirstChild(Objects[i]) 	
			local Value = player.Character:FindFirstChild(Objects[i])
			
			if Value and i == #objstate then
				--Player collected all the items 
				objstate[i] = true
				billboard.TextLabel.Text = tostring(i).." / 3" 

			elseif Value then
				--Player collected an item but not all
				objstate[i] = true
				billboard.TextLabel.Text = tostring(i).." / 3"

			else
				--Player don't have the item	
			end

			return;
		end
	end
end

clickDetector.MouseClick:Connect(function (playerWhoClicked)
	CheckItems(playerWhoClicked)
end)

it didnt even work. go onto the test server and try it for urself.

i tried it before giving it you and it’s working the reason it isn’t working for you i believe that the player has the tool locally and that’s why i suggested using client-sided

In short toggle to the server mode then assign the player the tool and it should be working. The way you are giving the players the tool is the issue. i just tested it now and it is working

yeah its still not working for me i tried doing that.

Make sure that the object/tool name is “Engine” and is being hold by the player

yup thats the name, all the parts are named correctly and im holding them.

Did you put it in workspace in the player?

here bro take a look at this script

local questItems = {"Engine", "Battery", "Tire"}
local playerProgress = {}
local TextValue = 0

function updateBillboard(player, currentStep)
	local billboard = script.Parent:FindFirstChild("Billboard")
	if billboard then
		local billboardGui = billboard:FindFirstChild("BillboardGui")
		local label = billboardGui:FindFirstChild("TextLabel")
		if label then
			label.Text = TextValue .. "/3"
		end
	end
end

function checkRequiredItem(player, currentStep)
	local progressData = playerProgress[player.UserId] or {}
	local requiredItem = questItems[currentStep]
	local hasRequiredItem = player.Backpack:FindFirstChild(requiredItem) -- Change here

	if hasRequiredItem then
		hasRequiredItem:Destroy()
		progressData.currentStep = currentStep + 1
		TextValue = TextValue + 1

		if currentStep == #questItems then
			progressData.completed = true
			print("Quest completed! Items removed from your inventory.")
		else
			print("Good job! Now bring me a " .. questItems[currentStep + 1] .. ".")
		end

		updateBillboard(player, progressData.currentStep)
	else
		print("You don't have the required item.")
	end

	playerProgress[player.UserId] = progressData
end

local clickDetector = script.Parent:WaitForChild("ClickDetector")

clickDetector.MouseClick:Connect(function(player)
	local progressData = playerProgress[player.UserId] or {}
	if not progressData.completed then
		checkRequiredItem(player, progressData.currentStep or 1)
	else
		print("You have already completed the quest.")
	end
end)

its in the npc this is what i want but the only problem is that when you equip the tool and try to click the npc you cant, you can only do it using the click detector.

ocal hasRequiredItem = player.Backpack:FindFirstChild(requiredItem)
thats the backpack only instead:

local hasRequiredItem = player.Character:FindFirstChild(requiredItem)

yeah i did that before but the problem is you cant click the npc with the tool out but thats what i want.

try putting it in the test server take a look at how it functions.

i will do that tomorrow i need to sleep now. bye!

Have you firstly searched on YouTube tutorials regarding “NPC quests”?

yeah dude nothing is like the one im trying to make.