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.
Hey Fatul,
local event = script.Parent; local cultivating = false; event.OnServerEvent:Connect(function(player, key) if key == "Z" then if cultivating == false then cultivating = true; else cultivating = false; end end print(cultivating) end)
~~ KingLoneCat