Server not receiving client

  1. What do you want to achieve?
    I’m trying to make an X and Y button for my plane
  2. What is the issue?
    Server isn’t receiving :FireServer() from the client
  3. What solutions have you tried so far?
    I’ve searched it up but nothing seems to be working

Local script

local usp = game:GetService("UserInputService")
local function test(input, gameProcessedEvent)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.Y then
				print("Y")
				local fire = script.Parent:WaitForChild("Y")
				fire:FireServer()
		end
		if input.KeyCode == Enum.KeyCode.X then
			print("X")
			local fireEvent = script.Parent:WaitForChild("EngineOff")
			fireEvent:FireServer()
		end
	end
end

usp.InputBegan:Connect(test)

Server script

local event = script.Parent.Controller:WaitForChild("Y")
local event2 = script.Parent.Controller:WaitForChild("EngineOff")
event2.Name = "RemoteEvent1"
local go = script.Parent.Parent.Go
local fx = script.Parent.Parent.Parent.Emitter.Effects

event.OnServerEvent:Connect(function()
	print("YS")
	go.Value = true
	fx.SFX:Play()
end)


event2.OnServerEvent:Connect(function()
	print("YS")
	go.Value = false
	fx.SFX:Stop()
end)

image

Thanks,

– Luke

Maybe remove event2.Name = "RemoteEvent1" from your server script?

that didn’t change anything with the results

Where are your scripts located at? Why not put the Remote Events in ReplicatedStorage?

because other scripts will listen for that event and fire a function on a different model

Okay. Where are your scripts located at though? Does everything print from your LocalScript, or does nothing print at all?

You should put the events in the replicated storage. The local script can’t fire the event if it located in a place like server storage.

u dont have anything in the parameters for fireserver() so maybethats why becuase it has nothing to send.and u dont have anything for the .onserverevent

I believe that is not the issue. You can use FireServer() without passing any arguments. You dont need to add anything in the OnServerEvent, if you are not doing anything for the specific player.

only prints from the local script when i test it

1 Like

Okay. Try using this code for your local script:

local UIS = game:GetService("UserInputService")

local Event1 = script.Parent:WaitForChild("Y")
local Event2 = script.Parent:WaitForChild("EngineOff")

local function test(input, typing)
	if typing then
		return
	end
	
	if input.KeyCode == Enum.KeyCode.Y then
		print("Y was pressed")
		Event1:FireServer()

	elseif input.KeyCode == Enum.KeyCode.X then
		print("X was pressed")
		Event2:FireServer()
	end
end

UIS.InputBegan:Connect(test)