If Statements in function not working through FireEvent

I am just getting back into scripting and I just learned how to use FireServer. I am trying to make a sort of on and off switch through this but I have had no luck

Heres my Server Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = Instance.new("RemoteEvent", ReplicatedStorage)
local part = script.Parent

createPartEvent.Name = "CreatePartEvent"

local function OnEventFire(player, isDown)
	local PosYD = 14.25
	local PosYU = 6.25
	
	if isDown == false then
		print('h')
		
	elseif isDown == true then
			print('e')
	end
end

createPartEvent.OnServerEvent:Connect(OnEventFire)

Heres my local script

local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local createPartEvent = ReplicatedStorage:WaitForChild("CreatePartEvent")

local isDown = false
UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E then
		if isDown == false then
			createPartEvent:FireServer(isDown)
			isDown = true
		end
		
		elseif isDown == true then
			createPartEvent:FireServer(isDown)
			isDown = false
	end
end)

I have tried running the isDown on the server side and the client side and neither have seemed to work. Any help would be greatly appreciated.

Here.Issue is here.
You put the elseif outside of the inner if statement.

1 Like