|
| 28 Feb 2015 04:00 PM |
why the hell wont this work
i have character indexed as
local player=game.Players.LocalPlayer char=player.Character
and lua decides to just go
NOPE NEVER HEARD OF THIS CHARACTER THING, ILL JUST GO OVER TO THIS OTHER SCRIPT THAT USES THE SAME EXACT THING AND WORK PROPERLY. |
|
|
| Report Abuse |
|
|
trituse
|
  |
| Joined: 03 Aug 2011 |
| Total Posts: 15618 |
|
|
| 28 Feb 2015 04:01 PM |
obviously its ebola
[PINK SQUID] |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 04:02 PM |
"char=player.Character"
is no "local" in front?
local char=player.Character |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 04:02 PM |
like here's just an example because imn not leaking the whole script
paste binny
/HfjVe621 |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 04:02 PM |
| It might be because the character hasn't loaded yet, try using player:WaitForChild("Character") |
|
|
| Report Abuse |
|
|
Qivr
|
  |
| Joined: 22 Aug 2014 |
| Total Posts: 5407 |
|
|
| 28 Feb 2015 04:02 PM |
Is it in a local script? And, sometimes it takes a while to get Character. so local character = player:WaitForChild("Character") |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 04:02 PM |
@demon
sorry i typoed that in the post, im anger typing |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 04:03 PM |
@qivr
that actually makes more sense |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 04:03 PM |
local player = game.Players.LocalPlayer repeat wait() until player.Character local character = player.Character
| Skelecore, clan of magic and wizardry | #RespectThePot |
|
|
| Report Abuse |
|
|
| |
|
|
| 28 Feb 2015 04:07 PM |
| THANK YOU MACHINE GOD FOR BLESSING THE C&GERS WITH THE KNOWLEDGE TO RELIEVE ME OF MY ANGER!!!!!!!!!!!! |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 04:13 PM |
the character isn't there. The player loads before the character does, so you're trying to get a nil object. so use what skel said.
"no you're being stupid." -General Astrochemistry |
|
|
| Report Abuse |
|
|
Parthax
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 6941 |
|
|
| 28 Feb 2015 04:21 PM |
| local character = player.CharacterAdded:wait() |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 04:28 PM |
@Parthax, that could cause problems if the character is already their. Try this, BIoodsport, it's your best option...
local character = player.CharacterAdded:wait() or player.Character
"no you're being stupid." -General Astrochemistry |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 04:40 PM |
Client code replicated via ReplicatedFirst or StarterGui (and I believe StarterPack) will always execute before the character is loaded in online mode. Therefore, CharacterAdded:wait() is a valid solution assuming you do NOT yield before trying to reference the character.
In the event you wish to have this work for both online and solo mode, use a simple while loop before referencing the character for a variable*: while not player.Character and #player.Character:GetChildren() < 10 do wait(0.03) end
* The reason you ought to use a while loop is because the condition is checked before executing code within the loop's scope. A repeat loop, executes the code before checking the condition. This means that a repeat loop will take milliseconds longer to break, which can actually be annoying in come cases.
Another note you should keep in mind is that player.Character is not an instance, it is a property that points to one. Simply doing player:WaitForChild("Character") will not work, because ::WaitForChild() does not work with properties. |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 04:42 PM |
| Let it also be noted that you could use a ternary operator, but if you want to ensure the character has fully loaded (or at least very close to it), my suggested while loop would more than suffice for that operation. |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 04:42 PM |
^
"no you're being stupid." -General Astrochemistry |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 04:46 PM |
ermagherd ruinable actually agreed with me on one thing
| Skelecore, clan of magic and wizardry | #RespectThePot |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2015 04:49 PM |
@Skele, not exactly, i primarily suggested ternary operator
"no you're being stupid." -General Astrochemistry |
|
|
| Report Abuse |
|
|