I am trying to make a simple gate, which opens and closes. The issue is that it won’t close. It just freezes.
Here is the Code.
Script
local Module = require(game:GetService("ReplicatedStorage").Modules.Funcs)
local isOpen = true;
game:GetService("Workspace").GateButton.ClickDetector.MouseClick:Connect(function(player)
if isOpen then
isOpen = false
Module.TweenGate(script.Parent.Post1, CFrame.Angles(0,math.rad(90),0), 3.5)
Module.TweenGate(script.Parent.Post2, CFrame.Angles(0,math.rad(-90),0), 3.5)
else
if not isOpen then
isOpen = true
print('Close')
Module.TweenGate(script.Parent.Post1, CFrame.Angles(0,0,0), 3.5)
Module.TweenGate(script.Parent.Post2, CFrame.Angles(0,0,0), 3.5)
end
end
end)
Module
local module = {}
local TweenService = game:GetService("TweenService")
function module.TweenGate(Post: Part, Angle, Time: number)
local Open1 = {CFrame = Post.CFrame * Angle}
local Info = TweenInfo.new(Time, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0,false,0)
local Tween1Open = TweenService:Create(Post, Info, Open1)
Tween1Open:Play()
end
return module