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

Touched and TouchEnded not firing????

idk why this script is not working

script.Parent.Touched:Connect(function(hit)
        print("hit")
	if hit.Name == "dttector" then
		print("Hit by dttector")
		script.Parent.Parent.a.Transparency = 1
		script.Parent.Parent.b.Transparency = 1
		script.Parent.Parent.c.Transparency = 1
		script.Parent.Parent.d.Transparency = 1
		script.Parent.Parent.e.Transparency = 1
	end
end)
script.Parent.TouchEnded:Connect(function()
		script.Parent.Parent.a.Transparency = 0.8
		script.Parent.Parent.b.Transparency = 0
		script.Parent.Parent.c.Transparency = 0
		script.Parent.Parent.d.Transparency = 0
		script.Parent.Parent.e.Transparency = 0
	
end)

the prints are not running. the Part is named "dttector".

3 comments

0

Try doing hit.Name so with uppercase N

0

Is this in a part?

0

yes it is a part

2 answers

Hello kittensgaming123! Remove line: 02. and make sure to inserted in dttector Part as a Script. The new script:

script.Parent.Touched:Connect(function(hit)
        script.Parent.Parent.a.Transparency = 1
        script.Parent.Parent.b.Transparency = 1
        script.Parent.Parent.c.Transparency = 1
        script.Parent.Parent.d.Transparency = 1
        script.Parent.Parent.e.Transparency = 1
    end)
script.Parent.TouchEnded:Connect(function()
        script.Parent.Parent.a.Transparency = 0.8
        script.Parent.Parent.b.Transparency = 0
        script.Parent.Parent.c.Transparency = 0
        script.Parent.Parent.d.Transparency = 0
        script.Parent.Parent.e.Transparency = 0

end)

I hope that helps you. Good luck.

1 comment

0

it mite work but the if is to stop players form opening the door so only sum parts can open the door

script.Parent.Touched:Connect(function(hit) if hit.name == "dttector" then -- I see one mistake here (Read the bottom for more detail(s))

	script.Parent.Parent.a.Transparency = 1
	 script.Parent.Parent.b.Transparency = 1
	script.Parent.Parent.c.Transparency = 1
	script.Parent.Parent.d.Transparency = 1
	script.Parent.Parent.e.Transparency = 1
	end
end)
script.Parent.TouchEnded:Connect(function()
script.Parent.Parent.a.Transparency = 0.8
script.Parent.Parent.b.Transparency = 0
script.Parent.Parent.c.Transparency = 0
script.Parent.Parent.d.Transparency = 0
script.Parent.Parent.e.Transparency = 0

end)

I think your if statement should say:

if hit:FindFirstChild("Humanoid") or hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid") then

-- If a player touched it, and the script found the "Humanoid" any code in here will run!

end

1 comment

0

the part named dttector is to stop player oping the door

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