Server to Client Remote Event not working (FE enabled)

I want to make it so that the remote event will fire and the local script will receive and do it. For some reason, either the localscript wont receive it or the event itself doesnt fire. Is there anything I can do to fix this? image

Script code:

local ship = script.Parent
local forwardforce = 0 – ignore these values for now
local leftforce = 0
local rightforce = 0
local backforce = 0

ship.Seat.Touched:Connect(function(thing)
local player = game.Players:GetPlayerFromCharacter(thing.Parent)
if player then
print(“firing”)
ship.RemoteEvent:FireClient(player)
print(“fired!”)
end
end)

Localscript code:

local ship = script.Parent
local cta = game:GetService(“ContextActionService”)

ship.RemoteEvent.OnClientEvent:Connect(function(nothing,player)

	print("getting player:"..player)
		local mouse = player:GetMouse()		
	if player then
		print("is player")
	    local function move (actionname,inputstate,input)
			if input == Enum.KeyCode.W then
				ship.RemoteEvent:FireServer("forward")
				print("forward")
			end
			if input == Enum.KeyCode.S then
				ship.RemoteEvent:FireServer("backward")
				print("back")
			end
			if input == Enum.KeyCode.A then
				ship.RemoteEvent:FireServer("leftwards")
				print("left")
			end
			if input == Enum.KeyCode.D then
				ship.RemoteEvent:FireServer("rightwards")
				print("right")
			end
			if input == Enum.KeyCode.Space then
				cta:UnbindAction("move")
				print("jumped")
			end
		end
	    cta:BindAction("move",move,true,Enum.KeyCode.A,Enum.KeyCode.D,Enum.KeyCode.W,Enum.KeyCode.S,Enum.KeyCode.Space) 	            
	end

end)

When I call fireserver() in another script, it works, and I understand remote events.
Output:

1 Like

The parameters(nothing,player) that you are trying to receive from the OnClientEvent, do not exist. You are sending nothing, other than the client to fire the event to. This means that both “nothing”, and “player”, will be nil. You are not actually passing anything to your OnClientEvent. You shouldn’t even need to player parameter anyway, since in a LocalScript you can just define the player through game.Players.LocalPlayer.

I don’t know if has to do with your firing problem, but I thought I would point it out.

In your server script, you should also make sure that the thing that fired the seats .Touched event, is actually a player character, before firing an event. You could end up trying to fire the event to a Part. xD

Make sure to create checks, like so:

ship.Seat.Touched:Connect(function(thing)
    if thing.Parent:FindFirstChild("HumanoidRootPart") then
        local player = game.Players:GetPlayerFromCharacter(thing.Parent) 
--ect.
1 Like

local scripts only work on the player or player gui or the players character

1 Like

Looks like there is no solution to this, looks like I’m going to use something else