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

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

Asked by 4 years ago
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

Log in to vote
0
Answered by 4 years ago

Remove the end on line 9.

0
thanks that worked, it was left over from a if statment i deleted and forgot to delet the end :/ adieking1 69 — 4y
Ad
Log in to vote
0
Answered by
gskw 1046 Moderation Voter
4 years ago
Edited 4 years ago

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!

Answer this question