Would my cooldown work in this case?

getting error Players.8Cert.PlayerScripts.RemoteLocalScript:30: Expected ‘end’ (to close ‘function’ at line 26), got ‘if’

wait(2)
local Players = game:GetService("Players")
local seat = game.workspace.ScriptedArtillery.ArtillerySeat
local player = Players.LocalPlayer
local IsSitting = false
local trajectorybeam = game.Workspace.ScriptedArtillery.End.TrajectoryMarker
local function onOccupantChanged()
	local humanoid = seat.Occupant
	IsSitting = (humanoid == player.Character.Humanoid)
end

local UserInputService = game:GetService("UserInputService")
local remoteEvent = game.ReplicatedStorage.ShootSmoke

local TimeSinceFPress = 0
local Cooldown = 5
function canUse()
	local CanUseRightNow = false
	local CurrentTime = tick()
	return CurrentTime - TimeSinceFPress >= Cooldown
		if CurrentTime - TimeSinceFPress >= Cooldown then
		CanUseRightNow = true
	else
		CanUseRightNow = false
		return CanUseRightNow
	end
end
	
seat:GetPropertyChangedSignal("Occupant"):Connect(onOccupantChanged)

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.F and IsSitting and CanUseRightNow then
		remoteEvent:FireServer()
		print("hi")
	end
end)

trajectorybeam.Enabled = false
while wait() do
	if IsSitting then
		trajectorybeam.Enabled = true
	else
		trajectorybeam.Enabled = false
	end
end```
x
	return CurrentTime - TimeSinceFPress >= Cooldown
		if CurrentTime - TimeSinceFPress >= Cooldown then
		CanUseRightNow = true
	else
		CanUseRightNow = false
		return CanUseRightNow
	end

What is going on here? You’re returning something and then you have an if statement. This isn’t allowed.

I fixed it but I’m not sure if this is still correct

local TimeSinceFPress = tick()
local Cooldown = 5
function canUse()
	
	if TimeSinceFPress >= Cooldown then
		CanUseRightNow = true
	else
		CanUseRightNow = false 
	end
	
	return CanUseRightNow
end```

You Do Not Need To Return Anything

looks fine to me, what the return statement does is that it passes the specified values to whatever called the function and terminates that function
for example:

function foo()
	return 5 -- anything after this line in this function is invalid
end

local bar = foo()
print(bar) -- output: 5