What do you want to achieve? Keep it simple and clear!
I’ve been experiencing this for a while now but its been getting annoying. Simple events like PlayerAdded and CharacterAdded aren’t even firing. (Note: This only happens in studio). The PlayerAdded only seems to work after I’ve rejoined a bunch of times and it makes testing very annoying
What is the issue? Include screenshots / videos if possible!
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I haven’t seen too much for my issue and the only fix just seems to be rejoining a bunch. Now I’m not 100% that CharacterAdded doesn’t fire in local scripts but I don’t think thats the problem since CharacterAppearanceLoaded fires. Then in my server handler PlayerAdded barely fires at all.
local player = Players.LocalPlayer
local viewportFrame = script.Parent.ViewportFrame
local part = viewportFrame:WaitForChild("Dummy")
local viewportCamera = Instance.new("Camera", viewportFrame)
viewportFrame.CurrentCamera = viewportCamera
viewportCamera.CFrame = (CFrame.new(0.75,0,-2) + part.Head.Position) * CFrame.Angles(0, math.rad(160), 0)
player.CharacterAdded:Connect(function(char)
print("starting")
wait(5)
for i, v in pairs(part:GetChildren()) do
if v:IsA("Accessory") then
v:Destroy()
end
end
for i, v in pairs(char:GetChildren()) do
if v:IsA("Accessory") then
char.Humanoid:AddAccessory(v:Clone())
end
end
end)
I would appreciate any help, solutions or whether this is an engine bug
I believe in this case, CharacterAdded isn’t working since the character is probably added by the time the script creates the event, so it doesn’t run. Whereas CharacterAppearanceLoaded will be made before the Character fully loads. Did you test out CharacterAdded after a respawn? If so, then it must be something else
For the CharacterAdded, it has to be that since it’ll recreate the event everytime before the character is fully loaded. For the PlayerAdded, could you show us the code?
If you made an event, an in the server script service you could FireAllClients of that event the moment after a Player.CharacterAdded event, and then from the local script, you could pick up that event and continue running that code as normal, except you would define the char variable as game.Players.LocalPlayer.Character since the event is fired, meaning there is no doubt that the character is not loaded in yet
-- Services
local DataStoreService = game:GetService("DataStoreService")
local ServerStorage = game:GetService("ServerStorage")
local Teams = game:GetService("Teams")
local ServerScriptService = game:GetService("ServerScriptService")
local StarterGui = game:GetService("StarterGui")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- Modules
local Info = require(script.Parent:WaitForChild("Config"))
local Ranks = require(script.Parent:WaitForChild("Ranks"))
local functions = require(script.FunctionsModule)
-- Events
local LoadCharacterEvent = ReplicatedStorage:WaitForChild("CharacterLoad")
local KillFeedEvent = ReplicatedStorage:WaitForChild("KillFeed")
-- Variables
local data
local amount = 0
local DataStore = Info.DataStore
local PlayerStorage = {}
-- Functions
functions:Start(Info, Ranks)
-- Events
Players.PlayerAdded:Connect(function(player)
print("player added")
-- code
end)
I think it could be that it sometimes works cause of all those require and WaitForChilds, they’re probably delaying the event creation and that could be why it sometiesm work and sometimes doesn’t. Try putting the event on the top of the script and see how likely it is to work
As you can see “yes” printed but not “player added” underneath. Also its loading because the server script didn’t fire. I thought this could be a possibility and thanks!
Edit: this what i added at the top of the script btw
I see, I’m glad to figured out the issue and I wish you good luck with trying to fix the other issues you may have after moving the event! If you have anymore issues don’t be afraid to ask!