local Spawner = Vector3.new(157.324, 0.974, 26.163)
local Clicker = script.Parent
local ObjectSpawn = script.Parent.Parent.Spawn
local debounce = false
Clicker.MouseClick:Connect(function(player)
if not debounce then
debounce = true
local Backpack = player:FindFirstChild("Backpack")
if Backpack ~= nil then
print "Check"
local Obj = Backpack:GetChildren()
if Obj == ("Bowl") then
local Object = game.ReplicatedStorage:findFirstChild("Bowl")
print "Bowl"
end
if Obj == ("Classic") then
local Object = game.ReplicatedStorage:findFirstChild("Classic")
print "Classic"
else
local Object = game.ReplicatedStorage:findFirstChild("Cardboard")
print "Cardboard"
script.Parent.Parent.BrickColor = BrickColor.new("Persimmon")
local CloneObject = Object:Clone()
CloneObject.Parent = game.Workspace
CloneObject:MoveTo(Spawner)
wait (12)
script.Parent.Parent.BrickColor = BrickColor.new("Shamrock")
debounce = false
end
end
end
end)
This script is meant to check if a player has an item in their inventory, and if so, spawn it. For some reason though, it always spawns cardboard. It is printing check, so I have found the player's backpack, but when I put either "Bowl" or "Classic" in the starter pack it still spawns cardboard. Also, nothing else is being printed. Why?

16 comments
try to loop through the children of the backpack and see if any of the children's name matches what you're searching for
don't set the default of object to cardboard
So I changed it so that now the default of Object isn't Cardboard and then I get this error: Workspace.SledSpawn.ClickDetector.Script:26: attempt to index global 'Object' (a nil value)
I was able to fix the error using "else" and now it is printing cardboard as well. However, it always print cardboard and never recognizes what Obj is.
thats because in your script Obj is a table. update your script to what you currently have.
done
gotta fix that formatting, is bad
I know I'm sorry I just started
you need to loop through the table based on length of table, you cant just check a table against a string like that
How would I know the length of the table?
Oh...Well I figured it out and with Classic in the backpack it read: 1= Classic ... so what I'm searching for is the child of the backpack
#Obj would return the length of the table
Yeah, that's what I used to do it
for i, v in pairs(Obj) do if v.Name == ("whatever") --do stuff end // thats the jist of what you're looking for
Thanks! now it is printing the name of whatever is in my inventory
just make an if / elseif for the names and wham bam.