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

Expected 'then' when parsing if statement, got <eof>?

Asked by 3 years ago

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)

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

i removed if and elseif at line 19, 21 and 25, you dont need it

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);
          part.Touched:Connect(function(hit)
                wait(2)
                   part.Touched:Connect(function(hit)
                            screen.Material = Enum.Material.Neon
                            SurfaceLight.Enabled = true
                    end) 
                    part.Touched:Connect(function(hit)
                            screen.Material = Enum.Material.SmoothPlastic
                            SurfaceLight.Enabled = false                            
                        end) 

                    end
end)
0
WARNING: use task.wait() instead of wait(), wait is outdated now. NGC4637 602 — 3y
0
@NGC4637 wait is not outdated, it's just not good to have so many of them because it waits longer than usual MarkedTomato 810 — 3y
Ad

Answer this question