Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I fix this script so a door would open/close when I click on it?

Ok, I was writing a Tween script where when you click on the door, it opens or closes depending on it's status. But the script is broken and I don't know what the problem is.

Here's the code:

local opener =  script.Parent
local tween = game:GetService("TweenService")
local opened = false
local pos = CFrame.new(30.75, 3, 141.375)
local rot = CFrame.Angles(0, math.rad(120), 0)

local tweenInfo =  TweenInfo.new(
	1,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	1,
	false,
	0
)

local goals = {
	opener.CFrame == pos * rot
}

local tweenData = tween:Create(opener, tween, goals)

local function onMouseClick()
	if opened == false then
		opened = true
		tweenData:Play()
	else
		opened = false
		pos = CFrame.new(28.75, 3, 139.875)
		rot = CFrame.Angles(0, math.rad(0), 0)
		tweenData:Play()
	end
end

opener.ClickDetector.MouseClick:Connect(onMouseClick)

1 answer

Hi! This Is How To Do It For No Collide Door:

script.Parent.MouseButton1Click:Connect(function()
script.Parent.CanCollode = False
wait(5) -- Change The Time To How Long It Stays Open
script.Parent.CanCollide = true
end)

Working On The Opening One

This discussion is preserved as it was. New answers, comments, and votes are closed.