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

Touched Script Stops Working After A While?

Hi! i have made a script which detects if a tool has touched a part, However, after a couple scans. The part no longer changes the text. Any work around for this? Any help is great, thanks in advance! Script:

local db = false
script.Parent.Touched:Connect(function(hit)
	if not db then
		db = true
	local h = hit.Parent.Name
	if h == "milk" then
			script.Parent.Parent.screen.SurfaceGui.Frame.TextLabel.Text = "Error, cannot purchase. Try again."
			wait(5)
			script.Parent.Parent.screen.SurfaceGui.Frame.TextLabel.Text = "Scan item >"
			db = false
	   end
	end
end)

1 answer

local db = false
script.Parent.Touched:Connect(function(hit)
    if not db then
        db = true
    local h = hit.Parent;h=h and h.Name
    if h == "milk" then
            script.Parent.Parent.screen.SurfaceGui.Frame.TextLabel.Text = "Error, cannot purchase. Try again."
            wait(5)
            script.Parent.Parent.screen.SurfaceGui.Frame.TextLabel.Text = "Scan item >"
           
       end
 db = false
    end

end)

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