|
| 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 |
|
|
|
| 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 |
|
|
| |
|
|
| 13 Aug 2016 06:10 PM |
| Level2 doesn't exist in script.Parent.Parent.Parent |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 13 Aug 2016 06:19 PM |
| Infinite yield possible on 'Workspace.Factory.Tycoon.Upgrader1:WaitForChild("Level2")' |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 13 Aug 2016 06:24 PM |
| WTF ROBLOX WHY ARE YOU DOING THIS |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
| |
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|
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 |
|
|
|
| 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 |
|
|