Making doors for an elevator

Lua doesn’t have a simple adding syntax to add/subtract to an existing variable, you need to do:

TOP_DOOR.Position = TOP_DOOR.Position + Vector3.new(0, 0.5, 0)
2 Likes

Yeah i know, thats why im telling you to make 4 extra doors, those doors will be a closed one and open one, the real doors will tween to the doors making it look like it opened and closed.

Im pretty sure lua does have a simple adding syntax to an existing variable.

Just using this quickly, thank you for replying! :grinning:

No, it doesn’t, most other different languages do.

Just like how Lua starts from 1, instead if 0.

Yes, it does. I’ve literally tried it.

times.Value += 1 seems to work very fine

Doesn’t work…

charrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

Because its the same thing as what thom told you

Can you make it something like my original script so I don’t have to keep going forwards and backwards trying to replicate the script?

local SIDE_DOOR = script.Parent.Parent.Doors.SIDE_DOOR
local TOP_DOOR = script.Parent.Parent.Doors.TOP_DOOR

function topDoor()
	for count = 16, 0, -1 do
		TOP_DOOR.Position = +0.5 -- the '+' is underlined in red
		wait(1)
	end
end

function sideDoor()
	-- help me here aswell
end

function startElevator()
	topDoor()
	wait(0.5)
	sideDoor()
end

script.Parent.ClickDetector.MouseClick:Connect(startElevator)

I agree lua is different, but the simple adding syntax does work perfectly

Sorry can you take a screenshot of where the ClickDetector is? Same with the script and where the doors are

sure, ill try to work my way through it

Wait why aren’t you using TweenService?

1 Like

explorertab

Because I do not know how to…

charrrrrrrrrrrrrrrrrrrrrrrr

What do you not understand?

Roblox has very good documentation on the Service.

Oooh right, give me a second

It seems interesting

I was telling you about using tween, does this elevator move up and down

Simple tween for position:

local TweenService = game:GetService("TweenService")

local partToTween : BasePart = nil -- get a basepart
local tweenInfo = TweenInfo.new() -- fill in data
local endPos : Vector3 = nil -- make a vector3 up

-- NOTE: you can also do CFrame, and many other data types.

local tween = TweenService:Create(partToTween, tweenInfo, endPos)

tween.Completed:Connect(function(playBackState)
	-- run code after it is done if you need
end)

tween:Play() -- Plays the tween

-- NOTE: there are other functions with tween, I recommend reading up on them.