-
What do you want to achieve? Be able to have CharacterAdded, PlayerAdded work
-
What is the issue? CharacterAdded and PlayerAdded is not firing.
-
What solutions have you tried so far? I tried checking if player.Character exists, or for loop through GetPlayers()
--[[ NoobsterStudio ]]--
local Players = game:GetService("Players")
local DefaultGravityValue = workspace.Gravity
local function onCharacterAdded(character: Model)
workspace.Gravity = DefaultGravityValue
end
local function onPlayerAdded(player: Player)
if player.Character then
onCharacterAdded(player.Character)
end
player.CharacterAdded:Connect(onCharacterAdded)
end
for _, player in pairs(Players:GetPlayers()) do
onPlayerAdded(player)
end
Players.PlayerAdded:Connect(onPlayerAdded)
This is a server script, and none of the events are just firing in the game. I added print statements and stuff but nothing is being printed.
is the server script inside of serverscriptservice?
works perfectly fine for me when used in serverscriptservice
--[[ NoobsterStudio ]]--
local Players = game:GetService("Players")
local DefaultGravityValue = workspace.Gravity
local function onCharacterAdded(character: Model)
print("character loaded")
end
local function onPlayerAdded(player: Player)
if player.Character then
onCharacterAdded(player.Character)
end
player.CharacterAdded:Connect(onCharacterAdded)
end
for _, player in pairs(Players:GetPlayers()) do
onPlayerAdded(player)
end
Players.PlayerAdded:Connect(onPlayerAdded)
There is no need for the
for _, player in pairs(Players:GetPlayers()) do
onPlayerAdded(player)
end
Since the server script will run before any player is within the game.
When that is said, I assume that the script is active, and that you’ve not turned off AutoCharacterLoading?
Yeah it’s in serverscriptservice
All the sudden it worked, I just waited an hour and then now all the sudden it works. Is this a bug? I didn’t change a single thing.