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

How do I make this "not hit" function work properly?

I made this script inside a part, that when touched, it becomes invisible, and when not touched, it appears again.

When I touch it, it turns invisible, but it stays like that even when I'm not touching it.

script.Parent.Touched:connect(function(HIT)
	local H = HIT.Parent:FindFirstChild("Humanoid")
	if H then
		script.Parent.Transparency = 1
	elseif not H then
		script.Parent.Transparency = 0
	end 
end)

1 answer

✓ Accepted answer

Use the TouchEnded event.

script.Parent.TouchEnded:connect(funtcion(HIT)
	local H = HIT.Parent:FindFirstChild("Humanoid")
		if H and script.Parent.Transparency == 1 then
			repeat wait() until H 
			script.Parent.Transparency = 0
		elseif not H then
			script.Parent.Transparency = 1
	end
end)

1 comment

0

Perfect! I didn't know such a function existed!

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