[SOLVED] OnClientEvent not detecting :FireClient()

What do you want to achieve?
Fire a client event and have a LocalScript detect that event

What is the issue?
The LocalScript won’t detect the event

What solutions have you tried so far?
I’ve tried looking on the DevForum for help, but nothing appears to be present in regards to what I’m looking for. I’ve tried changing all :FireClient() parameters to just the player and a tuple, but that won’t work.

ServerScript - Inside of ServerScriptService

local CharactersEvent = game:GetService("StarterGui"):WaitForChild("JoinCharacter"):WaitForChild("Frame"):WaitForChild("Characters")

game:GetService("Players").PlayerAdded:Connect(function(Player)
     local Characters = {nil, nil, nil}

     CharactersEvent:FireClient(Player, Characters)
     print("Characters event fired")
end)

Local Script - Inside of StarterGui

local CharactersEvent = script.Parent.Characters

CharactersEvent.OnClientEvent:Connect(function(Characters)
	print("Received characters event")
end)

I am getting “Characters event fired” in the Output panel, but I’m not getting “Received characters event”. I don’t know what’s wrong?

1 Like

If I had to guess, the event is firing before the client gets their LocalScript. In the snippet above, CharacterEvent fires when a player has joined. The character hasn’t loaded in yet and haven’t received their items from StarterGui when a player joins.

Did you mean to bind CharactersEvent to CharacterAdded instead?

I programmed a part inside the ServerScript where the event would not fire until I was loaded in, which it didn’t fire until I was in the game and fully loaded, but the event still was not detected in the local script.

Can you provide that? Hard to diagnose with missing information.

I just added: Players.CharacterAdded:Wait()

local CharactersEvent = game:GetService("StarterGui"):WaitForChild("JoinCharacter"):WaitForChild("Frame"):WaitForChild("Characters")

game:GetService("Players").PlayerAdded:Connect(function(Player)
     local Characters = {nil, nil, nil}

     Players.CharacterAdded:Wait()

     CharactersEvent:FireClient(Player, Characters)
     print("Characters event fired")
end)

CharactersEvent is being fired but you are firing the event located in StarterGui. The CharactersEvent in the local script references the one in PlayerGui. I’d recommend moving the event to ReplicatedStorage instead.

Try making the local script receive Player, Character instead of just Character. This is just a quick guess.

Found the solution

Instead of me trying to detect the player being added by using .PlayerAdded, I can just go into the LocalScript and fire a remote event to the main server script and then it can handle it from there.