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: Nil value

Previous Thread :: Next Thread 
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
13 Jul 2014 12:21 PM
It says
Workspace.Script:10: attempt to index local 'ob' (a nil value)
Did I do CFrame wrong?


game.Workspace.ChildAdded:connect(function(object)
local player = game.Players:playerFromCharacter(object)
if player ~= nil then
local lvl = player.leaderstats.Level.Value
print(lvl)
local ob = game.Workspace:FindFirstChild("Level"..lvl)
print(ob)
object.Torso.CFrame = object.Torso.CFrame + Vector3.new(0,3,0)
wait()
object.Torso.CFrame = ob.CFrame + Vector3.new(0,3,0)
end end)
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
13 Jul 2014 12:23 PM
also ob is just a part
Report Abuse
Vuva is not online. Vuva
Joined: 22 Jan 2010
Total Posts: 1102
13 Jul 2014 12:42 PM
is "print(ob)" returning nil? because that is the problem I'm pretty sure...
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
13 Jul 2014 12:51 PM
no
object.Torso.CFrame = ob.CFrame + Vector3.new(0,3,0) is returning nil
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
13 Jul 2014 12:53 PM
Workspace.Script:10: attempt to index local 'ob' (a nil value)

The problem is what it is...

It's attempting to find ob but ob's nil...


"object.Torso.CFrame = ob.CFrame + Vector3.new(0,3,0) is returning nil"
It's not returning anything, you're setting a value here
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
13 Jul 2014 12:55 PM
I see
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
13 Jul 2014 12:58 PM
But what should I do then?
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
13 Jul 2014 01:04 PM
Find out why "local ob = game.Workspace:FindFirstChild("Level"..lvl)" is nil
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
13 Jul 2014 01:09 PM
I have no clue. It prints lvl correctly and the part named Level 1 is there so idk :|
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
13 Jul 2014 01:10 PM
maybe you're missing a space
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
13 Jul 2014 01:21 PM
Wow back to bed haha :|
But now I get

Workspace.Script:8: bad argument #3 to 'CFrame' (CFrame expected, got userdata)
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
13 Jul 2014 01:22 PM
nvm fixed thanks for the help
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