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 » Scripters
Home Search
 

Re: !!!!!!!!!!!!Help me someone!!!!!!!!!!!!!!

Previous Thread :: Next Thread 
awiton is not online. awiton
Joined: 27 Apr 2012
Total Posts: 2656
20 May 2017 11:38 AM
local NPC = game.Workspace:FindFirstChild(script.Parent.Name)

while true do

wait()
if script.Parent.Job.Value == "Lumberjack" then
local trees = game.workspace.Map:GetChildren()
for i = 1 ,#trees do
local tree = trees:findFirstChild("Tree")
if tree ~= nil and tree[i]:FindFirstChild("Trunk")~= nil and (tree[i].Trunk.Position - script.Parent.Torso.Position).Magnitude < 100 then
NPC.Humanoid:MoveTo(tree[i].Trunk.Position)
NPC.Humanoid.MoveToFinished:wait()
else
wait(4)
game.Lighting.CantFindTrees:Clone().Parent = script.Parent.Head
script.Parent.Head.CantFindTrees.ConversationDistance = 25
wait(0)
end
end end end








=================================================================================
My output thingy says

"Line 9 - attempt to index a nil value" something/
Report Abuse
CelluloidCats is not online. CelluloidCats
Joined: 11 Aug 2015
Total Posts: 841
20 May 2017 11:41 AM
It was unable to find the Tree where you were looking.


Report Abuse
CelluloidCats is not online. CelluloidCats
Joined: 11 Aug 2015
Total Posts: 841
20 May 2017 11:43 AM
this code is rhetarded in so many ways, brb rewriting


Report Abuse
awiton is not online. awiton
Joined: 27 Apr 2012
Total Posts: 2656
20 May 2017 11:47 AM
local tree = trees:findFirstChild("Tree")
Report Abuse
CelluloidCats is not online. CelluloidCats
Joined: 11 Aug 2015
Total Posts: 841
20 May 2017 11:49 AM
This could be written better but I honestly wanted to die inside as I got close to the end of it

local NPC = game.Workspace:FindFirstChild(script.Parent.Name)
local hum = NPC:FindFirstChild("Humanoid")

while true do
local foundTree
wait()
if script.Parent.Job.Value == "Lumberjack" then
local trees = workspace.Map:GetChildren()
for _, v in pairs(workspace.Map:GetChildren()) do
if v.Name == "Tree" and v:FindFirstChild("Trunk") and (v:FindFirstChild("Trunk").Position -script.Parent:FindFirstChild("HumanoidRootPart").Position).Magnitude < 100 then
hum:MoveTo(v:FindFirstChild("Trunk").Position)
hum.MoveToFinished:wait()
print("found tree")
foundTree = true
break
end
end
end
if not foundTree then
wait(4)
local thingy = game.Lighting:FindFirstChild("CantFindTrees"):Clone().Parent = script.Parent:FindFirstChild("Head")
thingy.ConversationDistance = 25
end
end


Report Abuse
awiton is not online. awiton
Joined: 27 Apr 2012
Total Posts: 2656
20 May 2017 12:09 PM
YES IT WORKS!!!! THANKS SO MUCH!!! My game is one step closer to completion!!! Thank you so much i've been spending hours trying to figure out how to solve it. ya did it!
Report Abuse
CelluloidCats is not online. CelluloidCats
Joined: 11 Aug 2015
Total Posts: 841
20 May 2017 12:12 PM
you need to work on the logical processing in your code. That thing was a mess. If you get to that stage again just do ctrl+a then press backspace. It's better to work from scratch then try to fix something that you can't work with. Sadly that's how coding works. If it's baroque. Get rid of it. kek.


Report Abuse
awiton is not online. awiton
Joined: 27 Apr 2012
Total Posts: 2656
20 May 2017 02:12 PM
Here's my game i'm working on.
if ANYONE wants to visit it.


Please don't dislike its work in progress. :)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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