Scripting error

Can anyone tell me why is my script not working?

local Remote = game.ReplicatedStorage:WaitForChild("Remote"):WaitForChild("Notification")

local cooldown = false

Remote.OnClientEvent:Connect(function(msg, className)
	if cooldown == false then
		if msg == "AlreadyScanned" then
			cooldown = true
			game.StarterGui:SetCore("SendNotification", {
				Title = "Warning",
				Text = "You have already scanned your ticket.",
				Duration = 3
			})
		elseif msg == "NotScanned" then
			cooldown = true
			game.StarterGui:SetCore("SendNotification", {
				Title = "Access Denied",
				Text = "Pass required",
				Duration = 3
			})
		wait(2)
		cooldown = false
	end
end)

1 Like

seperate the wait(2) cooldown = false to be under the next end

local Remote = game.ReplicatedStorage:WaitForChild("Remote"):WaitForChild("Notification")

local cooldown = false

Remote.OnClientEvent:Connect(function(msg, className)
	if cooldown == false then
		cooldown = true
		if msg == "AlreadyScanned" then
			game.StarterGui:SetCore("SendNotification", {
				Title = "Warning",
				Text = "You have already scanned your ticket.",
				Duration = 3
			})
		elseif msg == "NotScanned" then
			game.StarterGui:SetCore("SendNotification", {
				Title = "Access Denied",
				Text = "Pass required",
				Duration = 3
			})
	end
	wait(2)
	cooldown = false
end)

You’re still missing an end for the nested if-statement