Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Touched and TouchEnded not firing????

Asked by 5 years ago
Edited 5 years ago

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".

0
Try doing hit.Name so with uppercase N Amiaa16 3227 — 5y
0
Is this in a part? Qariter 110 — 5y
0
yes it is a part kittensgaming123 19 — 5y

2 answers

Log in to vote
2
Answered by
Voxozor 162
5 years ago

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.

0
it mite work but the if is to stop players form opening the door so only sum parts can open the door kittensgaming123 19 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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

0
the part named dttector is to stop player oping the door kittensgaming123 19 — 5y

Answer this question