You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to achieve a quest system that can be completed once giving an NPC 4 items. -
What is the issue? Include screenshots / videos if possible!
The issue is that even though I am holding the item, the script just ignores it and doesn’t think I am holding the item.
Here is the code
GiveNugget.Triggered:Connect(function(player)
local Tool = player.Backpack:FindFirstChild("Nugget")
if player.Backpack:FindFirstChild("Nugget") or player.Character:FindFirstChild("Nugget") then
nuggetCounter += 1
print(nuggetCounter)
if nuggetCounter == 4 then
print("Done")
textLabel.Parent.CharacterName.Text = "Terry"
ProximityPrompt.Enabled = false
typewrite(textLabel, "thanks, here's some beans")
wait(2)
typewrite(textLabel, " ")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Tool = ReplicatedStorage.Tools["Beans"]:Clone()
for _,v in pairs(player.Character:GetChildren()) do
if v:IsA("Tool") then
print("Didn't pick up the tool! Inventory full")
end
end
for _,v in pairs(player.Backpack:GetChildren()) do
if v:IsA("Tool") then
print("Didn't pick up the tool! Inventory full")
end
end
if #player.Backpack:GetChildren() == 0 then
Tool.Parent = player.Backpack
script.Parent:Destroy()
end
end
else
print("Player doesn't have nugget")
end
end)
It just prints “Player doesn’t have nugget” even if I have a nugget
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have looked on the DevForum and tweaked my code for different results.
This is my first post so please let me know if I am doing anything wrong or if it’s not clear enough