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
Remove the end on line 9.
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!