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

Script that used to work doesn't seem to be anymore?

Not sure if it is due to an update but I'm receiving an error on line 38. If anyone has any suggestions that would be very helpful!

Error I get: 15:28:14.745 - The Parent property of InfoBox is locked, current parent: NULL, new parent PlayerGui

Again, didn't receive this error in the past? The model is a morph model. Basically copies the body of the humanoid in the model and pastes it on the player.

Thank you in advance, I appreciate any feedback!

local PlayersService = game:GetService("Players")

while (script:FindFirstChild("InfoRemover") == nil) do wait(0.001) end

local g = Instance.new("ScreenGui")
g.Name = "InfoBox"


local CanMorph = nil
local Lock = nil

local s = script.InfoRemover:Clone()
s.Parent = g
s.Disabled = false

script.Parent.BrickColor = BrickColor.new("Black")

function onTouch(hit)
	if (Lock == nil) then
		Lock = true
		script.Parent.BrickColor = BrickColor.new("Medium stone grey")

		CanMorph = nil
		BodyParts = hit.Parent:GetChildren()
		for i,b in pairs(BodyParts) do
			if (b.className == "Humanoid") then
				CanMorph = true
			end
			wait(0.001)
		end
		if (CanMorph == nil) then
			script.Parent.BrickColor = BrickColor.new("Black")
			Lock = nil
			return
		end

		script.Parent.BrickColor = BrickColor.new("Black")
		g.Parent = PlayersService:FindFirstChild(hit.Parent.Name).PlayerGui --here is where I get an error :/

		BodyParts = hit.Parent:GetChildren()
		for i,b in pairs(BodyParts) do
			if (b.className == "Accessory") or (b.className == "CharacterMesh") or (b.className == "Shirt") or (b.className == "Pants") or (b.className == "ShirtGraphic") then
				b:Destroy()
			end
			if (b.className == "Part") then
				if (b.Name == "Torso") then
					if (b:FindFirstChild("roblox") ~= nil) then
						b.roblox:Destroy()
					elseif (b:FindFirstChild("Decal") ~= nil) then
						b.Decal:Destroy()
					end
				end
				if (b.Name == "Head") then
					if (b:FindFirstChild("Mesh") ~= nil) then
						b.Mesh:Destroy()
					end
				end
			end
			wait(0.001)
		end

		BodyParts = script.Parent.Parent:GetChildren()
		for i,b in pairs(BodyParts) do
			if (b.className == "CharacterMesh") or (b.className == "Shirt") or (b.className == "Pants") or (b.className == "ShirtGraphic") then
				b:Clone().Parent = hit.Parent
			end
			if (b.className == "BodyColors") and (hit.Parent:FindFirstChild("Body Colors") ~= nil) then
				hit.Parent:FindFirstChild("Body Colors").HeadColor= b.HeadColor
				hit.Parent:FindFirstChild("Body Colors").LeftArmColor= b.LeftArmColor
				hit.Parent:FindFirstChild("Body Colors").LeftLegColor= b.LeftLegColor
				hit.Parent:FindFirstChild("Body Colors").RightArmColor= b.RightArmColor
				hit.Parent:FindFirstChild("Body Colors").RightLegColor= b.RightLegColor
				hit.Parent:FindFirstChild("Body Colors").TorsoColor= b.TorsoColor
			end
			if (b.className == "Part") then
				if (b.Name == "Torso") then
					if (b:FindFirstChild("roblox") ~= nil) then
						b.roblox:Clone().Parent = hit.Parent.Torso
					elseif (script.Parent.Parent.Torso:FindFirstChild("Decal") ~= nil) then
						b.Decal:Clone().Parent = hit.Parent.Torso
					end
				end
				if (b.Name == "Head") then
					if (b:FindFirstChild("face") ~= nil) then
						hit.Parent.Head.face.Texture = b.face.Texture
					elseif (script.Parent.Parent.Head:FindFirstChild("Decal") ~= nil) then
						hit.Parent.Head.face.Texture = b.Decal.Texture
					end
					if (b:FindFirstChild("Mesh") ~= nil) then
						b.Mesh:Clone().Parent = hit.Parent.Head
					end
				end
			end
			if (b.className == "Accessory") then
				local h = Instance.new("Accessory")
				h.Name = b.Name
				h.AttachmentPos = b.AttachmentPos
				b.Handle:Clone().Parent = h
				h.Parent = hit.Parent
			end
			wait(0.001)
		end

		g.Parent = nil
		script.Parent.BrickColor = BrickColor.new("Black")
		Lock = nil
	end
end

script.Parent.Touched:Connect(onTouch)

1 comment

0

It seems like whatever parent is locked. You change this by doing [PARENT].Locked = false

1 answer

g.Parent = nil

That line seems interesting (line 104). You can try setting the to game.ReplicatedStorage both right after creation and at line 104 instead of having it be nil (which I think would have caused that error).

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