Hey everyone. So, i am trying to fire a Character added event in a module script that functions locally. It works, but not at first… it doesn’t work when you first enter the game, but when you reset it works. Does anyone know what’s going on with that?
I tried also putting a player added event before it, but still nothing.
My guess is that when you’re playtesting it your character has already loaded in the game before the module script connected to the event. Try instead running a local server so the client joins a bit later.
Correct, since in game play the clients join later but in play solo it joins almost immediately. What you could also do is move the place where you require the module and the event connector to the top to try and have it run faster than playsolo.
That probably means your character is being added AFTER the event is initialized. Create a function that you want to run in your character added event and run that function as soon as the script initializes.
if Player.Character then
Hey guys, @azahid1@kinkocat i’m still having this issue, and the solutions you posed have not helped. I even have tried repeat wait() until player.Character aswell as repeat wait() workspace:FindFirstChild(player.Name)
At the beginning, when the game is loaded, the event connection can be loaded after the first character is added, so it won’t detect it. To solve the problem I do something like that:
function a(character) end -- function that is connected to the event
plr.CharacterAdded:Connect(a); -- here is the connection that you have
-- and you have to add something like that
for i,v in pairs(game.Players:GetChildren()) do
if v.Character then
a(v.Character); -- here execute the function a
So if a character had been added before the script was loaded and connections initialized, the code at the end will run and execute the function for all player characters in the game.
And I want to point out that you will not execute anything twice, because all the characters that will be affected by the code at the end, were not affected with the CharacterAdded event connection.
If you’re working locally, not on the server, simply do
local plr = game.Players.LocalPlayer;
local char = plr.Character;
if char then
at the end of the code instead of the loop from the first code.
repeat wait() until player.Character
if player.Character then
I hope I can solve it here. Alright so since your module is placed on the client, this means that things load in at differing times. The reason why your module script didn’t recognize the initial CharacterAdded event is because it ran too slow (after the initial character was spawned). It’s not much of an issue but if you want to get the most recent Character in workspace you can simply do the following:
local Character = Player.Character and Player.Character.Parent and Player.Character or Player.CharacterAdded:Wait()
If you are working with Aero Game Framework (I do quite frequently as well!), something that could be happening is that your event is firing late. That’s been pointed out a few times I know but it’s good to try creating a catcher function for these cases.
Considering the OP says that it’s a module that works locally, I’m going to assume that you’re making a controller. In this circumstance, you don’t need to do any PlayerAdded. Hook everything straight to the character event: you can.
local LocalPlayer = game:GetService("Players").LocalPlayer
local function onCharacterAdded(character)
if LocalPlayer.Character then
This should be what you’re looking for. If it’s not, mind providing me some details so I could attempt to repro the problem? I work a lot with Aero and don’t seem to have troubles with CharacterAdded or anything.
I’d leave it in the Start method. Init is for setting up your module’s resources if you need any during the code’s lifetime. This also includes access to other Aero modules (since modules are loaded first before services and controllers are initialised and started).