i get this error: Script:8: attempt to index field 'Parent' (a nil value)

local id = game.Workspace.Inmate:GetChildren()
local spawn = game.Workspace.InSpawns:GetChildren()
local player = script.Parent.Parent.Parent.Parent.Parent

function OnClicked()
	for d = 1, #id do
		if id[d].Value == "None" then
	        script.Parent.Parent.Parent.Parent.UI.Id.Value = id[d].Name
	        id[d].Value = player.Name
	        script.Parent.Parent.Parent.Parent.UI.Team.Value = "Inmate"
	        for u = 1, #spawn do
		        if spawn["Spawn"..u] then
			        local spwn = spawn["Spawn"..u]
			        player.Character.Torso.CFrame = CFrame.new(spwn[u].Position.x, spwn[u].Position.y + 3, spwn[u].Position.z)
			

			
		        end
	        end
	        local ui = script.Parent.Parent.Parent.Parent.UI:GetChildren()
	        for o = 1,#ui do
		        if ui[o].ClassName == "Frame" then
			    script.Parent.Parent.Parent.Parent.UI.Character.Visible = false
			    script.Parent.Parent.Parent.Parent.UI.Crafting.Visible = false
		        ui[o].Visible = true
		        end
	        end
	        script.Parent.Parent.Parent:remove()
		else
		    script.Parent.Parent.Full.In.Visible = true
		    wait(3)
		    script.Parent.Parent.Full.In.Visible = false
	    end
	end
end

script.Parent.MouseButton1Click:connect(OnClicked)

2 comments

0

Your error is saying a Parent on Line 8 doesn't exist (is nil). All I can say is check your hierarchy, we cannot tell you a problem if it is due to hierarchy for we do not see the setup of your GUI's,Scripts, etc.

0

i verified and every parent is fine :/