generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Club Houses » Clans & Guilds
Home Search
 

Re: anyone who knows scripting

Previous Thread :: Next Thread 
BIoodsport is not online. BIoodsport
Joined: 23 Jun 2008
Total Posts: 28030
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 is not online. trituse
Joined: 03 Aug 2011
Total Posts: 15618
28 Feb 2015 04:01 PM
obviously its ebola

[PINK SQUID]
Report Abuse
DemonTitan is not online. DemonTitan
Joined: 25 Apr 2010
Total Posts: 12775
28 Feb 2015 04:02 PM
"char=player.Character"

is no "local" in front?

local char=player.Character
Report Abuse
BIoodsport is not online. BIoodsport
Joined: 23 Jun 2008
Total Posts: 28030
28 Feb 2015 04:02 PM
like here's just an example because imn not leaking the whole script



paste binny

/HfjVe621
Report Abuse
IndyTheWindyCindy is not online. IndyTheWindyCindy
Joined: 26 Aug 2014
Total Posts: 539
28 Feb 2015 04:02 PM
It might be because the character hasn't loaded yet, try using player:WaitForChild("Character")
Report Abuse
Qivr is not online. 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
BIoodsport is not online. BIoodsport
Joined: 23 Jun 2008
Total Posts: 28030
28 Feb 2015 04:02 PM
@demon

sorry i typoed that in the post, im anger typing
Report Abuse
BIoodsport is not online. BIoodsport
Joined: 23 Jun 2008
Total Posts: 28030
28 Feb 2015 04:03 PM
@qivr

that actually makes more sense
Report Abuse
SkeletalOrigin is not online. SkeletalOrigin
Joined: 16 Aug 2012
Total Posts: 8359
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
BIoodsport is not online. BIoodsport
Joined: 23 Jun 2008
Total Posts: 28030
28 Feb 2015 04:07 PM
standby
Report Abuse
BIoodsport is not online. BIoodsport
Joined: 23 Jun 2008
Total Posts: 28030
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
BIoodraven is not online. BIoodraven
Joined: 14 Sep 2014
Total Posts: 11981
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 is not online. Parthax
Joined: 27 Apr 2011
Total Posts: 6941
28 Feb 2015 04:21 PM
local character = player.CharacterAdded:wait()
Report Abuse
BIoodraven is not online. BIoodraven
Joined: 14 Sep 2014
Total Posts: 11981
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
FriendlyBiscuit is not online. FriendlyBiscuit
Joined: 01 Dec 2012
Total Posts: 8991
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
FriendlyBiscuit is not online. FriendlyBiscuit
Joined: 01 Dec 2012
Total Posts: 8991
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
BIoodraven is not online. BIoodraven
Joined: 14 Sep 2014
Total Posts: 11981
28 Feb 2015 04:42 PM
^

"no you're being stupid." -General Astrochemistry
Report Abuse
SkeletalOrigin is not online. SkeletalOrigin
Joined: 16 Aug 2012
Total Posts: 8359
28 Feb 2015 04:46 PM
ermagherd ruinable actually agreed with me on one thing

| Skelecore, clan of magic and wizardry | #RespectThePot
Report Abuse
BIoodraven is not online. BIoodraven
Joined: 14 Sep 2014
Total Posts: 11981
28 Feb 2015 04:49 PM
@Skele,
not exactly, i primarily suggested ternary operator

"no you're being stupid." -General Astrochemistry
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Club Houses » Clans & Guilds
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image