So,I was making a script that only executes one time if it's Touched but everything was find until I added TouchedEnded event,why and how do I fix it?
I also got an error saying:
Workspace.Part.Script:12: unexpected symbol near 'then'
Script:
local Part = script.Parent
local Touched = false--Debounce
--------------------------
Part.Touched:connect(function(TouchedPart)
Touched = true
FoundHumanoid= TouchedPart.Parent:FindFirstChild("Humanoid")--Checks if it's a humanoid
if not FoundHumanoid then
print("You're not a Character "..TouchedPart.Name.." !")
Touched = false
else
if not Touched or Part.TouchedEnded:connect(function()
then
print("I haven't been touched!")
Touched = false
Part.Transparency = 1
else
Part.Transparency = 0.5
print("I've been touched")
end
end
end)
end)

2 comments
I got a new error saying: TouchedEnded is not a valid member of Part.
My mistake, it is "TouchEnded"