The TouchEnded part of this script is not working. Basically I am trying to make a part that changes to neon and does a fade effect on touch and when the player comes off the part, it goes back to ForceField and stops.
Script:
local part = script.Parent
local debounce = true
part.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid~= nil and debounce == true then
debounce = false
part.Transparency = 0.05
wait(0.05)
part.Transparency = 0.10
wait(0.05)
part.Transparency = 0.15
wait(0.05)
part.Transparency = 0.20
wait(0.05)
part.Transparency = 0.25
wait(0.05)
part.Transparency = 0.30
wait(0.05)
part.Transparency = 0.35
wait(0.05)
part.Transparency = 0.40
wait(0.05)
part.Transparency = 0.45
wait(0.05)
part.Transparency = 0.50
wait(0.05)
part.Transparency = 0.55
wait(0.05)
part.Transparency = 0.60
wait(0.05)
part.Transparency = 0.65
wait(0.05)
part.Transparency = 0.70
wait(0.05)
part.Transparency = 0.75
wait(0.05)
part.Transparency = 0.80
wait(0.05)
part.Transparency = 0.85
wait(0.05)
part.Transparency = 0.90
wait(0.05)
part.Transparency = 0.95
wait(0.05)
part.Transparency = 1.00
part.Material = Enum.Material.Neon
wait(0.05)
part.Transparency = 0.95
wait(0.05)
part.Transparency = 0.90
wait(0.05)
part.Transparency = 0.85
wait(0.05)
part.Transparency = 0.80
wait(0.05)
part.Transparency = 0.75
wait(0.05)
part.Transparency = 0.70
wait(0.05)
part.Transparency = 0.65
wait(0.05)
part.Transparency = 0.60
wait(0.05)
part.Transparency = 0.55
wait(0.05)
part.Transparency = 0.50
wait(0.05)
part.Transparency = 0.45
wait(0.05)
part.Transparency = 0.40
wait(0.05)
part.Transparency = 0.35
wait(0.05)
part.Transparency = 0.30
wait(0.05)
part.Transparency = 0.25
wait(0.05)
part.Transparency = 0.20
wait(0.05)
part.Transparency = 0.15
wait(0.05)
part.Transparency = 0.10
wait(0.05)
part.Transparency = 0.05
wait(0.05)
part.Transparency = 0.00
wait(0.05)
debounce = true
end
end)
part.TouchEnded:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid == nil then
part.Material = Enum.Material.ForceField
print("off")
end
end)

9 comments
Still doesn't work ;( Here's a video: https://gyazo.com/a8cca564e6f3e4d06ea0eb25722406e3 although the video cut a little early
is it supposed to be invisible when you step off of it? If so I made edits to my script
Not invisible but the material was supposed to be set to ForceField if a player is not touching the part. Thanks for all the help so far
Works great man! Just one thing that I want to know is if there is anyway to make it turn off smoother at the end. Like in this video, watch how it cuts off: https://gyazo.com/c24f36526dfc3a981af34960f2c35835 Any way to make a smoother transition?? Btw I deleted line 9 as I didn't want the part to be invisible.
I added back line 9, thought it was 0.95 when it was 0.05 XD
Ok. I will try to make it smoother your Welcome :)
Yh man thanks for all the help if you wanna see what I was doing with the script, I could link you the unfinished game
Nah its fine happy scripting :D
Mhm