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

Why can't it find Parent as a valid object?

Asked by 6 years ago
Edited 6 years ago

I'm working on a script that changes your stats when you finish a map. I'm getting an error after finishing the map. Apparently Parent is a nil value??

Error:

Workspace.Level1.Level_Content.Fundementals.Level_Finish.Script:10: attempt to index field 'Parent' (a nil value)

Script:

block
block
block
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
        game.Workspace[Player.PlayerStats.CurrentLevel.Value]:remove()
        Player.PlayerGui.Menu.LevelFrame.Visible = true
        Player.PlayerGui.Menu.LevelFrame[Player.PlayerStats.CurrentLevel.Value].BackgroundColor3 = Color3.new(.100, .50, .234)
        if Player.PlayerStats.Level.Value < script.Parent.Parent.Parent.Parent.Configurations.Level.Value then
            Player.PlayerStats.Level.Value = Player.PlayerStats.Level.Value + 1
        end
    end
end)
0
There is no "parent" on line 10.Your error is the wrong error, or the script is the wrong one. H4X0MSYT 536 — 6y
0
I have it spaced to line 10 let me fix PixelZombieX 8 — 6y
0
try removing one parent or accessing it a different way using a WaitForChild() or FindFirstChild() DrInfinitum 4 — 6y

Answer this question