I'm just a beginner scripter, but I can't seem to figure out how to actually end the script. Everything else is correct though.

local timetoclose = script.Parent["Time to close"].Value
local cooldown = script.Parent.Cooldown.Value
local CanOpen = true
local AntiGlitch = script.Parent.TempLock
local ActivateAG = true
local DoorCount = script.Parent["Number of doors"].Value

script.Parent.Button.ClickDetector.MouseClick:Connect()
	if AntiGlitch.Value ~= DoorCount then return end
	if script.Parent.Lock.Value == 1 then return end
	
	ActivateAG = script.Parent.AntiGlitch:Invoke()
	if CanOpen == false then return end
	CanOpen = false
	wait(1.5)
	script.Parent.Sounds1.Sound:Play()
	print("hi")
	for i = 1,24 do
		wait(0)
		script.Parent.Parent.Door2:SetPrimaryPartCFrame(script.Parent.Parent.Door2.PrimaryPart.CFrame*CFrame.new(-0.065,0,0))
		
	end
	wait(0.6)
	script.Parent.Sounds1.Sound3:Play()
	for i = 1, 48 do
		wait(0)
		script.Parent.Parent.Door2:SetPrimaryPartCFrame(script.Parent.Parent.Door2.PrimaryPart.CFrame*CFrame.new(-0.13,0,0))
		
	end
	script.Parent.Sounds1.Sound2:Play()
	wait(timetoclose)
	script.Parent.Sounds1.Sound:Play()
	
	for i = 1, 64 do
		wait(0)
		script.Parent.Parent.Door2:SetPrimaryPartCFrame(script.Parent.Parent.Door2.PrimaryPart.CFrame*CFrame.new(0.121875,0,0))
		
	end

wait(cooldown)
		CanOpen = true
		AntiGlitch.Value = (AntiGlitch.Value + 1)
		
end



2 comments

1

Line 8 is supposed to say script.Parent.Button.ClickDetector.MouseClick:Connect(function() and line 44 is supposed to say end)

0

Maybe try "end)"?