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: Dumb error message

Previous Thread :: Next Thread 
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 06:02 PM
Workspace.Factory.Tycoon.Upgrader1.Upgrade Basic Upgrader - 5,000.Head.Script:5: attempt to index local 'model' (a nil value)

I have no idea why. My identifier is fine!

local model = script.Parent.Parent.Parent:FindFirstChild("Level2")
Report Abuse
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 06:05 PM
help me please. It literally works fine in a different script I have in another locations. I know for fact I have the location right because when I use the autocompleteish thing in scripts, in gives me the option of what I'm looking for. But when I run the script, it doesn't work.
Report Abuse
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 06:10 PM
WHY
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
13 Aug 2016 06:10 PM
Level2 doesn't exist in script.Parent.Parent.Parent
Report Abuse
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 06:13 PM
But it does. I've checked it multiple times using the autocomplete-like tool. It is there.
Report Abuse
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 06:13 PM
Read the error.

Workspace.Factory.Tycoon.Upgrader1.Upgrade Basic Upgrader - 5,000.Head.Script:5: attempt to index local 'model' (a nil value)
Report Abuse
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 06:15 PM
If I remove the 'local' part it still says.

- Workspace.Factory.Tycoon.Upgrader1.Upgrade Basic Upgrader - 5,000.Head.Script:4: attempt to index global 'model' (a nil value)
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
13 Aug 2016 06:17 PM
I did read the error.
It doesn't exist at the time that line runs.

Try thisL
local model = script.Parent.Parent.Parent:WaitForChild("Level2")
Report Abuse
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 06:19 PM
Infinite yield possible on 'Workspace.Factory.Tycoon.Upgrader1:WaitForChild("Level2")'
Report Abuse
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 06:20 PM
The weird thing is that I have an identical script in another button elsewhere in the game that DOES work.
Report Abuse
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 06:24 PM
WTF ROBLOX WHY ARE YOU DOING THIS
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
13 Aug 2016 06:26 PM
Clearly it doesn't exist. Maybe another script is moving it or it wasn't there in the first place.


Report Abuse
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 07:03 PM
Hierarchy: Factory>Tycoon>Upgrader1>Upgrade Basic Upgrader>Script

Script: local model = script.Parent.Parent.Parent:FindFirstChild("Level2")
Upgradecost = 5000

upgradeStuff = model:clone()



model:remove()
owner = script.Parent.Parent.Parent.Parent.Parent.OwnerName
local ting = 0

function onTouched(hit)
if ting == 0 then
ting = 1
check = hit.Parent:FindFirstChild("Humanoid")

if check ~= nil then
if hit.Parent.Name == owner.Value then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:findFirstChild("leaderstats")

if stats ~= nil then
local cash = stats:findFirstChild("Cash")
if cash.Value > (Upgradecost-1) then

cash.Value = cash.Value - Upgradecost
local amount = script.Parent.Parent.Parent.UpgraderPart.Add
amount.Value = amount.Value + 10
upgradeStuff.Parent = script.Parent.Parent.Parent
script.Parent.Parent:remove()

end
end
end
end

ting = 0
end
end

script.Parent.Touched:connect(onTouched)



Error: - Workspace.Factory.Tycoon.Upgrader1.Upgrade Basic Upgrader - 5,000.Head.Script:4: attempt to index local 'model' (a nil value)
Report Abuse
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 07:04 PM
And it's now working....sometimes. After I restarted my computer, it works 50% on the time, and the other 50% of the time is doesn't work
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
13 Aug 2016 07:16 PM
Use waitforchild
Report Abuse
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 07:18 PM
That doesn't work. I tried it already, it says something to the effect of 'Infinite wait possible on (script location/line) Stack End

And it just worked again, but the next time I tried it, it didn't work.
Report Abuse
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 07:19 PM
I've been running the simulation over and over and keep getting different results. Sometimes it works and sometimes it doesn't.
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
13 Aug 2016 07:41 PM
Infinite yield possible is a warning, not an error. If you want to get rid of it just specify the timeout time which is the second argument.


Report Abuse
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 07:46 PM
How do I do that?
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
13 Aug 2016 07:47 PM
x = y:WaitForChild(z, 10)

if the child doesn't exist in 10 seconds then it just sets x to nil


Report Abuse
brennisawesome is not online. brennisawesome
Joined: 26 Oct 2012
Total Posts: 1658
13 Aug 2016 07:50 PM
Seems to have worked for now, If anything else goes wrong I might ask again. Thank you :)
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