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 » Game Creation and Development » Scripting Helpers
Home Search
 

Re: player.Character is nil?

Previous Thread :: Next Thread 
Perci1 is not online. Perci1
Joined: 24 Jan 2011
Total Posts: 1027
25 Apr 2014 04:56 PM
The script is local.

local tool = script.Parent
local hum = game.Players.LocalPlayer.Character.Humanoid


tool.Equipped:connect(function(mouse)
mouse.Button1Down:connect(function()
ani = Instance.new("Animation")
ani.AnimationId = "http://www.roblox.com/Asset?ID=154838001"
local aniTrack = hum:LoadAnimation(ani)
aniTrack:Play()
end)
end)


The output says that Character is nil. I don't understand it.
Report Abuse
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
25 Apr 2014 05:03 PM
I think you need to give the animation a parent.
Report Abuse
Perci1 is not online. Perci1
Joined: 24 Jan 2011
Total Posts: 1027
25 Apr 2014 05:06 PM
What should be its parent? Humanoid?

That doesn't explain why it says Character is nil, though.
Report Abuse
islandmaker2012 is online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
25 Apr 2014 05:07 PM
repeat wait() until game.Players.LocalPlayer.Character~=nil
local hum = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
Report Abuse
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
25 Apr 2014 05:11 PM
I just did some testing you need to put this line of code in at the top
game.Workspace:WaitForChild(game.Players.LocalPlayer.Name)
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
25 Apr 2014 05:17 PM
Do what islandmaker2012 said.


LocalScripts usually are executed before the Character is loaded. Therefore, you need to wait for the Character to exist first before trying to reference to it. I do basically the same thing islandmaker2012 said, but like this:

while (not player.Character) do Wait() end
Report Abuse
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
25 Apr 2014 05:18 PM
All 3 of the post are solutions any one will work...
Report Abuse
Perci1 is not online. Perci1
Joined: 24 Jan 2011
Total Posts: 1027
25 Apr 2014 05:20 PM
Alright, thank you.
Report Abuse
shotgreen999 is not online. shotgreen999
Joined: 29 Nov 2009
Total Posts: 376
25 Apr 2014 05:20 PM
wait a second CRAZYMAN32!!!!!!!!!! WOW
Would you mind looking at one of my post that needs help?
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
25 Apr 2014 05:29 PM
Its just another person helping. -_-

At the top of your script add

repeat wait() until game.Players.LocalPlayer

Dont check for the character.
Report Abuse
islandmaker2012 is online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
25 Apr 2014 05:55 PM
do check for the character,the character can take up to 6 seconds to load after the player enters..
Report Abuse
HeavenlyRobloxrox3 is not online. HeavenlyRobloxrox3
Joined: 02 May 2012
Total Posts: 101
25 Apr 2014 06:10 PM
Lol... I wish crazyman32 would reply to mine too :)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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