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)
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.