The first function does activate, but the second only when i respawn. This code is not mine, im using it to understand.
function onPlayerEntered(player) repeat wait() until player.Character ~= nil print(player.Character) local scr = script.TrySprintScript:Clone() scr.Parent = player.Character scr.Disabled = false player.CharacterAdded:Connect(function(char) print(char) local scr = script.TrySprintScript:Clone() scr.Parent = char scr.Disabled = false end) end
The second function only runs when the character is added i.e. the actual model of the player in the Workspace. .CharacterAdded
only runs once when the character is as said above. You do the repeat wait() until player.Character ~= nil
after the player joins the game which takes a second, while that happens the character is being added. Since the code waits for the character to be added once the player.CharacterAdded
listener is added the character is already added meaning it's not triggered. Once the player respawns their character is added into the workspace firing connecting the function.
I really hope I could explain this well enough just comment if you have any questions!