Im Making a Code where it does something where the function: game:GetService("Players").PlayerAdded Is Activated.
The Problem, is that Dont makes Nothing, Even If I make it Correctly.
Is that your full script? If not, chances are that you have some asynchronous function before the connection is made, therefore not firing in time. If possible, please provide it as it will give us a better idea on how to navigate the issue.
local players = game:GetService('Players')
local pAdded = function(player)
end
for _, ok in next, players:GetPlayers() do -- looping existing players [specially if they have bad internet connection]
pAdded(ok)
end
players.PlayerAdded:Connect(pAdded) -- using the event to log others
I see. It’s probably because IIRC, calling an external module is going to yield the thread until something is successfully returned, you should make another thread that halts your .PlayerAdded function until the module is successfully required.
local runService = game:GetService('RunService')
local Module
coroutine.wrap(function()
Module = require(6995411300)
end)()
game:GetService("Players").PlayerAdded:Connect(function(player)
repeat runService.Heartbeat:Wait() until Module
player.CharacterAdded:Connect(function(Chara)
Module.Load(Chara:WaitForChild("HumanoidRootPart"), true, true, true, 10)
end)
end)