So I wrote a code to have a GUI click to teleports players into a train car seat. But it shows this error keep popping up.
Error: 14:39:01.992 - Players.Player.PlayerGui.ScreenGui.LocalScript:14: 'then' expected near '<eof>'
Script:
local Track1 = script.Parent.Background:WaitForChild("Track1")
local Track3 = script.Parent.Background:WaitForChild("Track3")
local Track4 = script.Parent.Background:WaitForChild("Track4")
local player = game.Players.LocalPlayer
if script.Parent.Track1.MouseButton1Click:connect(function()
torso = player.Character:WaitForChild("Torso")
humanoid = player.Character:WaitForChild("Humanoid")
if torso and humanoid then
torso.CFrame = CFrame.new(game.Workspace.R62_Trk1.Model.VehicleSeat + Vector3.new(0, 3, 0))
script.Parent.Background:Destroy()
end
end)

1 comment
Remove the 'if' on line 06.