If statement not checking

Im trying to make a bag place system however for some reason when interacted nil or with a bag it just does not print?

script.Parent.Triggered:Connect(function(Clicked)
	print("PLAYER INTERACTED")
	if Clicked.leaderstats.BagType == "BeginnerBag" then
		print("BAG TYPE IS BEGINNER BAG")
		local BeginnerBag = game.Workspace.BeginnerTelescopeStuff.BeginnerBagsFolder.BeginnerBag
		local BeginnerBagClone = BeginnerBag:Clone()
		
		BeginnerBagClone.Position = script.Parent.Parent.Position
	end
	
	if Clicked.leaderstats.BagType == nil then
		warn("NO BAG TYPE")
		return
	end
end)

Script is parented to the proximity prompt that is parented to the part i want to place the bag at

Whenever you make a clone, it’s parent will automatically be nil (correct me if I’m wrong), so you’ll want to parent it to Workspace yourself. Hope this helps!

try this

script.Parent.Triggered:Connect(function(Clicked)
	print("PLAYER INTERACTED")
	if Clicked.leaderstats.BagType.Value == "BeginnerBag" then
		print("BAG TYPE IS BEGINNER BAG")
		local BeginnerBag = game.Workspace.BeginnerTelescopeStuff.BeginnerBagsFolder.BeginnerBag
		local BeginnerBagClone = BeginnerBag:Clone()
		
		BeginnerBagClone.Position = script.Parent.Parent.Position
	end
	
	if Clicked.leaderstats.BagType.Value == nil then
		warn("NO BAG TYPE")
		return
	end
end)
1 Like

What is BagType? Is it like an ObjectValue?

Seeing thats its in leaderstats its most likely some sort of value but he didnt say that, so i just guessed he was missing the .Value

Still does not detect if its a nil value
DADAWDW

Yea that’s what I thought aswell

The bag type thing is a string value

try this

script.Parent.Triggered:Connect(function(Clicked)
	print("PLAYER INTERACTED")
	if Clicked.leaderstats.BagType.Value == "BeginnerBag" then
		print("BAG TYPE IS BEGINNER BAG")
		local BeginnerBag = game.Workspace.BeginnerTelescopeStuff.BeginnerBagsFolder.BeginnerBag
		local BeginnerBagClone = BeginnerBag:Clone()
		
		BeginnerBagClone.Position = script.Parent.Parent.Position
   elseif Clicked.leaderstats.BagType.Value == nil then
      warn("NO BAG TYPE")
      return
   end
end)

It still only prints player interacted not “no bag type”

try this and tell me what it prints

script.Parent.Triggered:Connect(function(Clicked)
	print("PLAYER INTERACTED")
    print(Clicked.leaderstats.BagType.Value)
   --[[
   if Clicked.leaderstats.BagType.Value == "BeginnerBag" then
		print("BAG TYPE IS BEGINNER BAG")
		local BeginnerBag = game.Workspace.BeginnerTelescopeStuff.BeginnerBagsFolder.BeginnerBag
		local BeginnerBagClone = BeginnerBag:Clone()
		
		BeginnerBagClone.Position = script.Parent.Parent.Position
   elseif Clicked.leaderstats.BagType.Value == nil then
      warn("NO BAG TYPE")
      return
   end
   ]]
end)
script.Parent.Triggered:Connect(function(Clicked)
	print("PLAYER INTERACTED")
	if Clicked.leaderstats.BagType.Value == "BeginnerBag" then
		print("BAG TYPE IS BEGINNER BAG")
		local BeginnerBag = game.Workspace.BeginnerTelescopeStuff.BeginnerBagsFolder.BeginnerBag
		local BeginnerBagClone = BeginnerBag:Clone()
		
		BeginnerBagClone.Position = script.Parent.Parent.Position
	
	else
		warn("NO BAG TYPE")
		return
	end
end)

dWADWAADW

try this

script.Parent.Triggered:Connect(function(Clicked)
	print("PLAYER INTERACTED")
    print(type(Clicked.leaderstats.BagType.Value))
   --[[
   if Clicked.leaderstats.BagType.Value == "BeginnerBag" then
		print("BAG TYPE IS BEGINNER BAG")
		local BeginnerBag = game.Workspace.BeginnerTelescopeStuff.BeginnerBagsFolder.BeginnerBag
		local BeginnerBagClone = BeginnerBag:Clone()
		
		BeginnerBagClone.Position = script.Parent.Parent.Position
   elseif Clicked.leaderstats.BagType.Value == nil then
      warn("NO BAG TYPE")
      return
   end
   ]]
end)

also try this tell me what it prints

script.Parent.Triggered:Connect(function(Clicked)
	print("PLAYER INTERACTED")
    print(Clicked.leaderstats.BagType)
   --[[
   if Clicked.leaderstats.BagType.Value == "BeginnerBag" then
		print("BAG TYPE IS BEGINNER BAG")
		local BeginnerBag = game.Workspace.BeginnerTelescopeStuff.BeginnerBagsFolder.BeginnerBag
		local BeginnerBagClone = BeginnerBag:Clone()
		
		BeginnerBagClone.Position = script.Parent.Parent.Position
   elseif Clicked.leaderstats.BagType.Value == nil then
      warn("NO BAG TYPE")
      return
   end
   ]]
end)

If I’m right, a StringValue’s value can’t be nil.

dadsa

script.Parent.Triggered:Connect(function(Clicked)
	print("PLAYER INTERACTED")
	if Clicked.leaderstats.BagType.Value == "BeginnerBag" then
		print("BAG TYPE IS BEGINNER BAG")
		local BeginnerBag = game.Workspace.BeginnerTelescopeStuff.BeginnerBagsFolder.BeginnerBag
		local BeginnerBagClone = BeginnerBag:Clone()
		
		BeginnerBagClone.Position = script.Parent.Parent.Position
	
	else
		warn("NO BAG TYPE")
		return
	end
end)

This should work I think

2 Likes

Thanks
real quick what did you change so i dont make the same mistake?

Or this:

script.Parent.Triggered:Connect(function(Clicked)
	print("PLAYER INTERACTED")
	if Clicked.leaderstats.BagType.Value == "BeginnerBag" then
		print("BAG TYPE IS BEGINNER BAG")
		local BeginnerBag = game.Workspace.BeginnerTelescopeStuff.BeginnerBagsFolder.BeginnerBag
		local BeginnerBagClone = BeginnerBag:Clone()
		
		BeginnerBagClone.Position = script.Parent.Parent.Position
	elseif Clicked.leaderstats.BagType.Value == "" then
		warn("NO BAG TYPE")
	end
end)