Why is it not printing?

Its not printing on Touched but it prints v

yes the PrimaryPart has been set
yes they’re tagged correctly

WHY IS IT NOT PRINTING HIT

v.PrimaryPart.Touched:Connect(function(hit)
	print(hit)
end)

are you using for loops? if so can you send a screenshot of the rest of the script

oh sorry i thought i did

for index, v in CollectionService:GetTagged("Pad") do
	local defaultPrice = 15

	local newPrice = defaultPrice * (index + 1)
	v:SetAttribute("Price", newPrice)

	if v:GetAttribute("isDefaultPad") then
		v:SetAttribute("Price", defaultPrice)
	end

	local billboardgui = v:FindFirstChild("Pad"):FindFirstChild("BillboardGui")

	billboardgui.Cost.Text = "$"..FormatNumberAlt.FormatCompact(v:GetAttribute("Price"))
	print(v)
	v.PrimaryPart.Touched:Connect(function(hit)
		print(hit)
	end)
end

place the .Touched function at the beginning of the loop, possible reason is probably the rest of the code that is not working

the previous code works having it at the beginning wouldn’t effect it

is “v” a model? if so does it have a primarypart set?

read the post i said
yes the PrimaryPart has been set
yes they’re tagged correctly

answer these questions

  • does it print “v”
  • will you show me the explorer
  • how do you know the previous code works

1 read the post it clearly says it does print v the problem is its not printing hit
2
image

3 i already tried what you said before i posted this

show me the rest of the explorer, and properties

  • do you have CanTouch enabled?

image
why would you need to see the rest of explorer?
image

Im not the best at scripting, and this seems pretty obvious, but when you are trying to get it to print, is it touching the primary part of the model or the model itself? I believe the event will only fire if something touches the primary part.

its not printing when i touch it

FOR DEBUGGING PURPOSES ONLY, try to print a random message and tell me if it prints, make it print outside and inside of the function. Tell me what happens and I can try to solve your problem.

I FIXED IT i just had to call it somewhere else

2 Likes