My OnClientEvent doesn't seem to be receiving

My firing

SCIremote:FireClient(player,"FlightinfoHere",Status,Time,Gate,Destination,Aircraft,Flightnum)

My receiver

local function update(player,info,Status,Time,Gate,Destination,Aircraft,Flightnum)

print("ClientRecieved")

print(player.Name)

end

remote.OnClientEvent:Connect(update)

The client receiver doesn’t seem to work for some reason.

Any errors in the script? Also, what are the variables SCIremote and remote?

Nope, I tested print and its normal everything fired
I even tested the fireclient for player.name and it printed the name so yeah.

The client already knows who the player is with local player = game.Player.LocalPlayer so it doesn’t need to send the player from the server to the client.

 local player = game.Player.LocalPlayer
    local function update(info,Status,Time,Gate,Destination,Aircraft,Flightnum)

    print("ClientRecieved")

    print(player.Name)

    end

    remote.OnClientEvent:Connect(update)

You will still have to keep player in the parameters in the FireClient(player… because then the server knows who to send it to.

1 Like

It is because the first parameter of your update function: “player”. Since the remote is fired towards a client, you do not need to index the player target from the receiving client.

U forgot an S in player but it still doesn’t receive anything.
I put these together so Idk if it causes a problem?

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remote = ReplicatedStorage.SCI

local player = game.Players.LocalPlayer

---------------------------------------------------------------------

while true do

remote:FireServer("flightinfo")

print("FiredServer")

wait(30)

end

local function update(info,Status,Time,Gate,Destination,Aircraft,Flightnum)

print("ClientRecieved")

print(player.Name)

end

remote.OnClientEvent:Connect(update)

See if this causes the problem, I removed it and it still doesn’t recieve. ^^^^^

I turned it into this and it worked lol.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remote = ReplicatedStorage.SCI

local player = game.Players.LocalPlayer

---------------------------------------------------------------------

local function update(info,Status,Time,Gate,Destination,Aircraft,Flightnum)

print("ClientRecieved")

print(player.Name)

end

while true do

remote:FireServer("flightinfo")

print("FiredServer")

remote.OnClientEvent:Connect(update)

wait(30)

end

Might be your while true do loop, move your update function into a dummy function as such:

-- update function
remote.OnClientEvent:Connect(function(...)
-- function
end)
1 Like
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remote = ReplicatedStorage.SCI

local player = game.Players.LocalPlayer

---------------------------------------------------------------------



local function update(info,Status,Time,Gate,Destination,Aircraft,Flightnum)

print("ClientRecieved")

print(player.Name)

end

remote.OnClientEvent:Connect(update)
while true do

remote:FireServer("flightinfo")

print("FiredServer")

wait(30)

end

Put your while loop at the very end. No other code is being read because it is in front of it all.

I see thanks you. --------------------------------------------------

If it is resolved then do mark one of the reply as the solution, for the sake of organization.


also do not do this because every 30 seconds it’ll create a new event for remote and then when the server fires to the client the client will fire multiple times

How long should I do it then? ------------------------------------

Like this. Look at the difference. The remote.OnClientEvent:Connect(update) is before the while loop and not in it.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remote = ReplicatedStorage.SCI

local player = game.Players.LocalPlayer

---------------------------------------------------------------------



local function update(info,Status,Time,Gate,Destination,Aircraft,Flightnum)

print("ClientRecieved")

print(player.Name)

end

remote.OnClientEvent:Connect(update)
while true do

remote:FireServer("flightinfo")

print("FiredServer")

wait(30)

end