Do I have to add an “else end” after an “if” statement? If so, how do I format it?
My code:
a.Doors.OpenR.MouseButton1Click:connect(function()
local s1 = Instance.new("Sound")
s1.SoundId = ("rbxassetid://5774103930")
s1.Parent = sound1
s1.Volume = 2
if script.Parent.Parent.VehicleSeat.Throttle = 0 then
s1:Play()
train.Car1.Body.Doors.R["1"].R.Door.CanCollide = false
train.Car1.Body.Doors.R["1"].L.Door.CanCollide = false
train.Car1.Body.Doors.R["1"].R.Door.PrismaticConstraint.TargetPosition = -3
train.Car1.Body.Doors.R["1"].L.Door.PrismaticConstraint.TargetPosition = -3
train.Car1.Body.Doors.R["1"].R.Door.PrismaticConstraint.Speed = 3
train.Car1.Body.Doors.R["1"].L.Door.PrismaticConstraint.Speed = 3
train.Car1.Body.Doors.R["2"].R.Door.CanCollide = false
train.Car1.Body.Doors.R["2"].L.Door.CanCollide = false
train.Car1.Body.Doors.R["2"].R.Door.PrismaticConstraint.TargetPosition = -3
train.Car1.Body.Doors.R["2"].L.Door.PrismaticConstraint.TargetPosition = -3
train.Car1.Body.Doors.R["2"].R.Door.PrismaticConstraint.Speed = 3
train.Car1.Body.Doors.R["2"].L.Door.PrismaticConstraint.Speed = 3
train.Car1.Body.Doors.R["3"].R.Door.CanCollide = false
train.Car1.Body.Doors.R["3"].L.Door.CanCollide = false
train.Car1.Body.Doors.R["3"].R.Door.PrismaticConstraint.TargetPosition = -3
train.Car1.Body.Doors.R["3"].L.Door.PrismaticConstraint.TargetPosition = -3
train.Car1.Body.Doors.R["3"].R.Door.PrismaticConstraint.Speed = 3
train.Car1.Body.Doors.R["3"].L.Door.PrismaticConstraint.Speed = 3
wait(1.3)
s1:Destroy()
end
end)
I’ve tried using else end but the text was red, with a syntax error.