I believe they mean why the script only functions on the server.
I would assume its because on the client, the script is added to the client after the player joins, so it wouldn’t detect the join of whichever client it is running on.
This is a good point. I am also suspicious if maybe LoadStat contains data store calls, which only work on the server. One would have to step through it to see for sure.
If nostalgic is right then you need to move that function outside of Connect(). It should still be connected, but then it should also be called manually for the local player.
function YourFunction(plr)
Carregar(plr)
...
end
plrs.PlayerAdded:Connect(YourFunction)
YourFunction(plrs.LocalPlayer)
Player added will Not fire for the localplayer in a localscript. It can only detect other players joining.
That is because the localscripts will only load after playeradded fires for the local player. Therefore the localscripts miss the event associated with the localplayer
To fix this, remove the whole playeradded bracket:
local plr = game:GetService(“Players”).LocalPlayer
local LevelUpHandler = require(script.LevelUpHandler)
local Upar = LevelUpHandler.LevelUp
local LoadStats = require(script.LoadStats)
local Carregar = LoadStats.LoadStat
Carregar(plr)
plr.CharacterAdded:Connect(function(chr)
local hum = chr:WaitForChild(“Humanoid”)
local leaderstats = plr:WaitForChild(“leaderstats”)
local lv = leaderstats:WaitForChild(“LOVE”)
I just realized the problem is not solved. I am not using local script to run the script, I am using a normal one. I am trying to make a leveling system althought it just loads for the server not for the player that was added.