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)
Events don't need to be used as conditionals [actually, they shouldn't be in general]
Merely remove the 'if' in front of the event declaration on line 06.
Also, you can't add an objectvalue to a Vector3 directly, so you must state that you want the 'VehicleSeat's position.
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 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(workspace["R62_Trk1"].Model.VehicleSeat.Position + Vector3.new(0, 3, 0)) script.Parent.Background:Destroy() end end)