Server
script.Parent.OnServerEvent:connect(function(player, currentKey)
local cultivating = false
local toggle = false
if currentKey == "Z" then
if cultivating == false then
cultivating = true
else
cultivating = false
end
else return end
print(cultivating)
end)
Local
local UIS = game:GetService('UserInputService')
UIS.InputBegan:connect(function(input, gameProcessedEvent)
if not gameProcessedEvent then
local currentKey = input.KeyCode.Name
workspace.Events.Main:FireServer(currentKey)
end
end)
It always returns true. Never goes true, then false, then true, etc.
I've messed with a lot of variations so far and it appears to me any type of FE event just cant handle toggles all that well.

2 comments
Where is the script and where is the remote event?
Local script is in StarterPlayerScripts, workspace.Events.Main is the remote event.