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

How do you fix 'expected ')' (to close '(' at line 5) got 'end' Because it doesn't make sense?

local tp1 = script.Parent
local tp2 = script.Parent.Parent.Telepart
local db = true
	 
tp1.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid")then
	local player = game.Players:GetPlayerFromCharacter(hit.Parent) 
	local lift = script.Parent.Parent.Parent.Name
	end
	   local gui = player.PlayerGui.LeaveTp
	   if db == true then
	       db = false
	       hit.Parent:MoveTo(tp2.Position) 
	       wait(0.2)
	       if player.PlayerGui.LeaveTp.LeaveButton.Visible == true then 
	           player.PlayerGui.LeaveTp.LeaveButton.Visible = false
	       end  
	       player.PlayerGui.LeaveTp.LeaveButton.Visible = true
	       db = true
	       player.LiftNumber = lift  
	   end
	end
end)

The error message is the title I don't understand what is wrong with the script

2 answers

✓ Accepted answer

Remove the end on line 9.

1 comment

0

thanks that worked, it was left over from a if statment i deleted and forgot to delet the end :/

Your script has a syntax error, which is obscured by incorrect indentation. Let's indent it properly:

local tp1 = script.Parent
local tp2 = script.Parent.Parent.Telepart
local db = true

tp1.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid")then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent) 
        local lift = script.Parent.Parent.Parent.Name
    end
    local gui = player.PlayerGui.LeaveTp
    if db == true then
           db = false
           hit.Parent:MoveTo(tp2.Position) 
           wait(0.2)
           if player.PlayerGui.LeaveTp.LeaveButton.Visible == true then 
               player.PlayerGui.LeaveTp.LeaveButton.Visible = false
           end  
           player.PlayerGui.LeaveTp.LeaveButton.Visible = true
           db = true
           player.LiftNumber = lift  
    end
end
end)

That makes it easier to spot, doesn't it? The code has one end too many.

To fix it, simply remove the extra end:

local tp1 = script.Parent
local tp2 = script.Parent.Parent.Telepart
local db = true

tp1.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid")then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent) 
        local lift = script.Parent.Parent.Parent.Name
        local gui = player.PlayerGui.LeaveTp
        if db == true then
           db = false
           hit.Parent:MoveTo(tp2.Position) 
           wait(0.2)
           if player.PlayerGui.LeaveTp.LeaveButton.Visible == true then 
               player.PlayerGui.LeaveTp.LeaveButton.Visible = false
           end  
           player.PlayerGui.LeaveTp.LeaveButton.Visible = true
           db = true
           player.LiftNumber = lift  
    end
end)

In the future, remember to apply indentation rules. Whenever there is a function(...), if ... then, for ... do, while ... do, repeat or do in your code, increase the indentation level by 1. Whenever there is an end or until ... in your code, decrease the indentation level by 1. I hope this helps!

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