I'm trying to make a door that will go up when the button is clicked, and when it's clicked again the door will go down but the door goes up at the start of the game for no reason, the output says nothing.
local tweenService = game:GetService("TweenService")
local seconds = 10.104
local isOn = false
function on()
isOn = true
script.Parent.Sound:Play()
tweenService:Create(script.Parent, TweenInfo.new(seconds, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = CFrame.new(104.855, 4.757, -148.31)}):Play()
end
function off()
script.Parent.Sound:Play()
tweenService:Create(script.Parent, TweenInfo.new(seconds, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = CFrame.new(104.87, -4.885, -148.2)}):Play()
end
function onClicked()
if isOn == true then off() else on() end
end
workspace.Button.ClickDetector.MouseClick:connect(onClicked)
on()
Thanks if you can help.

1 comment
Omg I always forget about is Connect