Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Error: attempt to index nil with 'FindFirstChild' How to fix this?

Asked by 4 years ago
Edited 4 years ago

I have a game similar to ToH. The tower changing script sometimes does not work. The script works fine with no problems for some time, then randomly it stops working. I get an error message on line 146 saying: attempt to index nil with 'FindFirstChild' This is my script:

001-- Services Variables
002local ReplicatedStorage = game:GetService("ReplicatedStorage")
003local ServerStorage = game:GetService("ServerStorage")
004local Players = game:GetService("Players")
005 
006-- ServerStorage Variables
007local StagesFolder = ServerStorage:WaitForChild("Stages")
008local Stages = StagesFolder:GetChildren()
009 
010-- Workspace Variables
011local Tower = game.Workspace:WaitForChild("Tower")
012local Storage = game.Workspace:WaitForChild("Storage")
013local Lobby = Storage:WaitForChild("Lobby")
014local End = Storage:WaitForChild("End")
015local SpawnsModel = Lobby:WaitForChild("Spawns")
View all 183 lines...

1 answer

Log in to vote
0
Answered by 4 years ago

Maybe try getting the Character with this:

1v.Character or v.Characteradded:Wait():FindFirstChild("Win")

I'm not very sure if this actually works, but it's always worth a try!

0
I tried it and it gave this error: Win is not a valid member of Model "Workspace".SpongebobRules26 SpongebobRules26 0 — 4y
0
The error was on line 147: v.Character.Win:Destroy() SpongebobRules26 0 — 4y
Ad

Answer this question