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

What does this error code mean?

Asked by
sad_eyez 162
8 years ago

I got this error code while helping a friend make a scare maze:

13:47:20.777 - The Parent property of Scare is locked, current parent: NULL, new parent PlayerGui

Heres my code:

local gui = script.Parent.Scare
local scream = script.Parent.Scream
local debounce = false
script.Parent.Touched:connect(function(hit)
    local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
    if not plr.PlayerGui:FindFirstChild("Scare") then
    gui:Clone()
    gui.Parent = plr.PlayerGui
    scream:Play()
    wait(4)
    scream:Stop()
    gui:Destroy()
    end
end)
0
try hit.Parent.Parent. Sometimes using hit can get buggy... dragonkeeper467 453 — 8y

1 answer

Log in to vote
1
Answered by
RedCombee 585 Moderation Voter
8 years ago
Edited 8 years ago

You have to break up your code into a couple more parts.

Line 6: if not plr.PlayerGui:FindFirstChild("Scare") then If the brick doesn't receive a player, it doesn't have a PlayerGui. First, you should check to see if game.Players can actually get a player from the "character" that is hit.Parent.

Essentially, you'd need two if statements.

script.Parent.Touched:connect(function(hit)
    player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        if not player.PlayerGui:FindFirstChild("Scare") then
            -- Code here
        end
    end
end)

Now, I do not know what "scare" is, so if this doesn't fix your problem, you need to give more information.

0
if the player was nil, it wouldn't have given that error, it has something to do with line 1 FutureWebsiteOwner 270 — 8y
Ad

Answer this question