Help With Ticket System

I am building a ticket scanner system for my game. I have a script that approves or declines entry through a scanner depending on the tool the player is holding. However, the scanners seem to randomly break and refuse to accept any .Touched events.

Script:

local allowedTicketNames = {
	"Ticket"
}

local opener = require(script.Parent.Parent.ManageDoor)

local debounce = false

script.Parent.Touched:Connect(function(part)
	if debounce == false then
		debounce = true
		
		print("touched")

		local toolExists = nil

		if part.Parent:FindFirstChildOfClass("Tool") then
			toolExists = part.Parent:FindFirstChildOfClass("Tool")
		elseif part:IsA("Tool") then
			toolExists = part
		elseif part.Parent:IsA("Tool") then
			toolExists = part.Parent
		end

		if toolExists then
			print("tool detected")

			if table.find(allowedTicketNames,toolExists.Name) then
				print("approved")
				opener:ApproveEntry()
			else
				print("declined")
				opener:EntryDeclined()
			end
		end
		
		task.wait(0.125)
		
		debounce = false
	end
end)
1 Like

Could you provide more information?

Is it correctly going through the whole script?
Is the debounce actually setting back to false?

Print a Value under debounce = false
And see if it actually reaches it.

1 Like

I found the issue:
Forgot to anchor some parts :sweat_smile:

I can’t believe I didn’t consider that

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.