Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

3 comments

0

WARNING: use task.wait() instead of wait(), wait is outdated now.

0

@NGC4637 wait is not outdated, it's just not good to have so many of them because it waits longer than usual

This discussion is preserved as it was. New answers, comments, and votes are closed.