Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What does this error code mean?

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)

1 comment

0

try hit.Parent.Parent. Sometimes using hit can get buggy...

1 answer

✓ Accepted answer

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.

1 comment

0

if the player was nil, it wouldn't have given that error, it has something to do with line 1

This discussion is preserved as it was. New answers, comments, and votes are closed.