Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I check to see if the whole character's loaded?

Asked by
Zerio920 285 Moderation Voter
9 years ago

I'm using a script that makes use of BodyForce so the character can jump higher, by checking the masses of every part of the character and using the total weight of all the parts. However, sometimes the character loads too early and the script isn't able to detect every part of the character, resulting in a smaller BodyForce and thus a smaller jump. How can I wait until every part of the character's loaded before using the script?

0
If I were you I would just be lazy and do a wait(3) or something at the top, although there's is very likely a better method. Perci1 4988 — 9y
0
I'm sure there's a better method. Don't wanna do an arbitrary wait though since I wanna get people in the game as soon as the thing loads. Not to mention some players might load longer than 3 seconds which would mess the whole thing up. Zerio920 285 — 9y
0
Player.CharacterAdded:wait() should wait until the character is fully loaded? But this will only work when the player spawns. NotsoPenguin 705 — 9y

1 answer

Log in to vote
2
Answered by 9 years ago

CharacterAdded

You can really just use the CharacterAdded event to make sure that the character is fully loaded just as NotsoPenguin has stated in the comments:

game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(s)
--do body force action here
print("Character Loaded!")
end)
end)

Or even if you are using a local-script, you can do something as the following:

local plr = game.Players.LocalPlayer
local chr = plr.Character or plr.CharacterAdded:wait()
print("Character Loaded!")
--do body force action here

Now, if you are waiting for hats to be loaded in or so, you can also add:

game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(s)
repeat until s.ChildAdded:wait() == "Hat"
print("Character Loaded!")
end)
end)

Useful Links

http://wiki.roblox.com/index.php?title=API:Class/Player/CharacterAdded http://wiki.roblox.com/index.php?title=User:JulienDethurens/Essays/Wait_method

Ad

Answer this question