Door opening up & down ISSUE ( Script HELP )

I’m trying to make a door that opens up and down when a button is clicked, but it isn’t really working. When you click the button, I want it to close the door, but if you press it again, I want it to to open the door. I followed this tutorial on YouTube, but the door doesnt seem to work.


local Stringvalue = script.Parent.Status

local TweenService = game:GetService("TweenService")

local DoorClose = {}
DoorClose.CFrame = door.CFrame * CFrame.new(0,-8,500,0)
local DoorOpen = {}
DoorOpen.Cframe = door.CFrame

local Doortime = TweenInfo.new(0.5)


local dooropen = TweenService:Create(door,Doortime,DoorOpen)

local doorclose = TweenService:Create(door,Doortime,DoorClose)

local dooropen = TweenService:Create(door,Doortime,DoorOpen)

local clickdetector = script.Parent:WaitForChild("ClickDetector")

clickdetector.MouseClick:Connect(function()
	if Stringvalue.Value == "OPENED" then
		doorclose:Play()
		Stringvalue.value = "CLOSED"
		script.Parent.Material = Enum.Material.Neon
		script.Parent.BrickColor = BrickColor.Green()
	elseif Stringvalue.Value == "CLOSED" then
		dooropen:Play()
		script.Parent.Material = Enum.Material.Glass
		script.Parent.BrickColor = BrickColor.White()
	end
end)

It also says there is something wrong with “DoorClose” but I can’t seem to find what…
image
image

YouTube Tutorial I Used

Please Help!!!

1 Like
DoorClose.CFrame = door.CFrame * CFrame.new(0,-8,500,0)
local DoorOpen = {}
DoorOpen.Cframe = door.CFrame

Here you see DoorOpen.Cframe instead of CFrame, fix that

2 Likes

Yes, thank you that worked, but the door only opens once and closes once, do you know how to make it so when the player pressed it opens/closes as many times as they want?

You need to set the door’s stringvalue back to “OPENED” then it’ll work

tysm it worked i cant believe it was that simple

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.