Door animation not working

Hello fellow scripters!

I’m trying to animate and script a door, and I can’t find any relevant information. The only good source I find is this video: https://www.youtube.com/watch?v=zTrwGZQCgTs

Here is the code:

local door = script.Parent.Door
local closePlaceholder = script.Parent.DoorClosed
local openPlaceholder = script.Parent.DoorOpened
local clickDetector = door.ClickDetector
local closeSound = door.Close
local openSound = door.Open

local debounce = true
local isOpened = false

local info = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
local closeProperties = (CFrame = closePlaceholder.CFrame)
local openProperties = (CFrame = openPlaceholder.CFrame)
local closeTween = game.TweenService:Create(door, info, closeProperties)
local openTween = game.TweenService:Create(door, info, openProperties)

clickDetector.MouseClick:Connect(function()
	if debounce then
		debounce = false
		if not isOpened then
			openSound:Play()
			openTween:Play()
		else
			closeSound:Play()
			closeTween:Play()
		end
		isOpened = not isOpened
		wait(1)
		debounce = true
	end
end)

I have everything labeled correctly from the script to workspace, but I am getting this error code: Expected ‘)’ (to close ‘(’ at column 25), got ‘=’; did you mean to use ‘{’ when defining a table? In the video it worked really well, and it’s from April. Other people in the comments are having the same problem, not sure if it’s the code or what’s happening.

Anyone have some tips or a solution to this?

Try replacing

local closeProperties = (CFrame = closePlaceholder.CFrame)
local openProperties = (CFrame = openPlaceholder.CFrame)

with

local closeProperties = {["CFrame"] = closePlaceholder.CFrame}
local openProperties = {["CFrame"] = openPlaceholder.CFrame}

The syntax you have used is not correct for creating a dictionary / table. That is why you are getting that error.

another way to index and define a dictionary could be as followed:

local closeProperties = {}
closeProperties.CFrame = closePlaceholder.CFrame

local openProperties = {}
openProperties.CFrame = openPlaceholder.CFrame
1 Like

Thanks! That worked perfectly!

1 Like