Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Touched Event not firing?

Basically, im getting nothing at all when this part is touched...

local pipeNumber = 1


script.Parent.Touched:Connect(function(hit)
	local model = hit.Parent:FindFirstChild'Humanoid'
	if model then 
		local plr = game.Players:FindFirstChild(hit.Parent.Name)
		if plr:FindFirstChild("PipesPassed") then 
			local pipesPassed = plr:FindFirstChild("PipesPassed")
			if pipesPassed.Value > pipeNumber then 
				pipesPassed.Value = 1 
				local plrcoins = game:GetService("ReplicatedStorage"):WaitForChild("LockedBanks"):FindFirstChild(plr.Name)
				plrcoins.Value = plrcoins.Value + 1
				print("success")
			end
		end
	else
		print("error")
	end
end)

1 answer

✓ Accepted answer

A few debugging tips, as well as code tips. When using FindFirstChild(), do it like FindFirstChild("Humanoid"). The way you have it looks bad, and might be the reason you have issues.

A way to see if your part is truly being touched is to put a print right after the event. print("Whatever you want") is one idea you could put. When I debug my code, I often end up adding several dozens of prints and remove them as needed.

Another reason the code might not be running, is that maybe model isn't a thing.

This discussion is preserved as it was. New answers, comments, and votes are closed.