Hi, my code keeps getting this error message. I've tried adjusting the 'end's, rewriting the code and looking at multiple different forums to find other solutions. These having not worked. , I'm really lost. Any help/clues or criticism is appreciated.
local part = script.Parent;
local Players = game:GetService("Players");
local screen = script.Parent.Parent.Screen
local SurfaceLight = screen.SurfaceLight
local part = script.Parent
part.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid");
if humanoid then
local player = Players:GetPlayerFromCharacter(hit.Parent);
screen.Material = Enum.Material.Neon
SurfaceLight.Enabled = true
end
part.TouchEnded:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid");
if humanoid then
local player = Players:GetPlayerFromCharacter(hit.Parent);
if part.Touched:Connect(function(hit)
wait(2)
if part.Touched:Connect(function(hit)
screen.Material = Enum.Material.Neon
SurfaceLight.Enabled = true
end) then
elseif part.Touched:Connect(function(hit)
screen.Material = Enum.Material.SmoothPlastic
SurfaceLight.Enabled = false
end) then
end
end)

3 comments
WARNING: use task.wait() instead of wait(), wait is outdated now.
https://eryn.io/gist/3db84579866c099cdd5bb2ff37947cec
@NGC4637 wait is not outdated, it's just not good to have so many of them because it waits longer than usual